Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving an old version of a Google Cloud function source

I accidentally lost my up to date source file of a cloud function and then deployed again the cloud function with an old version of it.

Each time I deploy a cloud function I see on the console the version id of the deploy.

Is there something I can do to roll back to the previous version of the source file?

like image 978
Ariel Avatar asked Oct 17 '17 19:10

Ariel


People also ask

What is the history of Google cloud?

Google Cloud Platform was launched on April 7th, 2008. A brief history of Google Cloud involves launching an App Engine to make it easy for companies to start work and release new apps. Initially, they released it only to a few customers and developers – companies that had millions of users.


3 Answers

I finally figured this out:

Each time you make a deploy to a cloud function you get an output line like this:

sourceArchiveUrl: gs://my-store-bucket/us-central1-function_name-xxoxtdxvxaxx.zip

I entered my Google Cloud Platform Developer Console -> Cloud Functions -> function_name -> Source tab

and there almost at the bottom it says: Source location

my-store-bucket/us-central1-function_name-xxoxtdxvxaxx.zip

the same as it was shown in the CLI, but without gs:// that link lead me to the following: https://storage.cloud.google.com/my-store-bucket/us-central1-function_name-........

I removed from the link everything that came after

https://storage.cloud.google.com/my-store-bucket

and that lead me to a huge list of files that each one of them represented a an image of all my cloud functions at the time point of each time i have made a deploy, exactly what i needed!

The only thing left to do was to locate the file with the last date before my mistaken deploy

like image 96
Ariel Avatar answered Nov 15 '22 11:11

Ariel


The following shows where to locate and restore a previous deployment version of your Google Cloud Function.

You can select each of your previous versions on the scrolldown menu at the top left of your GCF screen once you enter a function.

On this overview page, while NOT entering EDIT mode, you can select some previous versions (although not all) from the menu - the selected version is then deployed (here: Version 5).

enter image description here

like image 21
Agile Bean Avatar answered Nov 15 '22 10:11

Agile Bean


When you deploy a new version of a CF the code is store in a GCS bucket.This bucket only stores the last 2 deployed versions. You can set a retention policy to keep older versions of the CF.

The name of the bucket it's similar to something like this:

gcf-source-[ID]-[region of the function]

A workaround to restore old version of a CF would be to download the code from the bucket and redeploy the function with it.

like image 39
drauedo Avatar answered Nov 15 '22 11:11

drauedo