google-app-enginegoogle-cloud-platformgoogle-managed-vm

Rollback Google App Engine Managed VM


I updated my Managed VM code and deployed it over the current deployment. I then deleted the old deployment.

There is a bug in my new deployment, but because I deleted the old deployment, I can't go back to the old version!

How can I get my old deployment back without redoing everything? I want to minimize downtime.


Solution

  • I would highly reccomend having at least one previous version running at all times, just so you can switch back instantly if there is a problem.

    However, because the Container images are saved, you can roll back using this trick:

    Let's say your first deployment is version 'v1' and your second is 'v2'

    1. gcloud preview app deploy app.yaml --promote --version v1
    2. make some code changes
    3. gcloud preview app deploy app.yaml --promote --version v2
    4. delete v1 in console for some reason or another
    5. oh no! v2 has a bug! users are mad!
    6. oh no! I deleted v1 and can’t instantly switch back to it with zero downtime!
    7. gcloud preview app deploy app.yaml --promote --version v1 --image-url appengine.gcr.io/vm-containers.<your-project-id>.appspot.com/<your-project-id>.default.v1
    8. 2-4 minutes of downtime
    9. App starts working again at version v1