I'm running a Google App Engine production server, using basic_scaling as the scale type. Whenever I update the code and deploy it - using gcloud app deploy - the old version of the code is shutdown.
According to the documentation, that's expected:
The shutdown process might be triggered by a variety of planned and unplanned events, such as:
- You manually stop an instance.
- You deploy an updated version to the service.
- ...
I understand that it's easier for most developers that way. But in my case, I'd like to keep the old versions running until the idle_timeout limit is reached. Does anyone know if there's a way to avoid the automatic shutdown and let the old versions to shutdown by themselves?
Just to note that I have not created versions on my own. App Engine keep using the "default" version whenever I push new code.
It depends a little on what you are trying to do, but I think looking at versions is a good first step to try.
You can give a deployment a specific version id, not have it promoted and the choose to warm it up and then migrate to it.
For example to deploy a new version but not send traffic you can run:
gcloud app deploy --version VERSION_ID --no-promote
Then to migrate to it you can use:
gcloud app services set-traffic --splits VERSION_ID=1 --migrate
More details - depending on which language you are using these pages provide more information (I assume Node.js as that was in the link you shared) :
https://cloud.google.com/appengine/docs/standard/nodejs/migrating-traffic
https://cloud.google.com/appengine/docs/standard/nodejs/configuring-warmup-requests
Then you might be able to monitor instances of the old version and clean up as required. Perhaps using a Cloud Scheduler task with a Workflow, just an idea.