I am running a Node.js app on Google App Engine, using the following command to deploy my code:
gcloud app deploy --stop-previous-version
My desired behavior is for all instances running previous versions to be terminated, but they always seem to stick around. Is there something I'm missing?
I realize they are not receiving traffic, but I am still paying for them and they cause some background telemetry noise. Is there a better way of running this command?
Example output of the gcloud app instances list
:
As you can see I have two different versions running.
Google may have updated their documentation cited in @IAmKale's answer
Seems like that flag only works with manually scaled services.
We accidentally blew through our free Google App Engine credit in less than 30 days because of an errant flexible instance that wasn't cleared by subsequent deployments. When we pinpointed it as the cause it had scaled up to four simultaneous instances that were basically idling away.
That led me down the rabbit hole that is
--stop-previous-version
. Here's what I've found out so far:--stop-previous-version
doesn't seem to be supported anymore. It's mentioned under Flags on thegcloud app deploy
reference page, but if you look at the top of the page where all the flags are listed, it's nowhere to be found.I tried deploying with that flag set to see what would happen but it seemingly had no effect. A new version was still created, and I still had to go in and manually delete the old instance.
There's an open Github issue on the gcloud-maven-plugin repo that specifically calls this out as an issue with that plugin but the issue has been seemingly ignored.
At this point our best bet at this point is to add
--version=staging
or whatever togcloud deploy app
. The reference docs for that flag seem to indicate that that it'll replace an existing instance that shares that "version":(emphasis mine)
Additionally, Google's own reference documentation on app.yaml (the link's for the Python docs but it's still relevant) specifically calls out the
--version
flag as the "preferred" way to specify a version when deploying: