App Engine Instances kept alive after new version installation - google-app-engine

Every time I upload a new version of my app engine, the old version automatically stops. But in one of my projects, there is a bug, and every time I upload a new versions, it does not kill the older version. This bug result in me paying for 16 different running instances last month because we had a lot of new versions:
How can I make sure it never happen again?

gcloud app deploy does not remove previous versions
tl;dr: Use the --version flag when deploying to specify a version name. An existing instance with the same version will be replaced then next time you deploy.

Related

When publishing how to have only the latest version

I have a WPF application which i publish in intranet, the thing is i published the application 20 times till now, so i have 20 folders and the size of the build becomes more, i manually delete and leave only 2 latest versions, but is there a way to only have latest version to be published?
Right now i save in folder and then copy to inetpub\wwwroot, but if i had to send the files directly using Visual Studio, i have speed issues due to weak intranet lines in some branches.
but is there a way to only have latest version to be published?
You are already only publishing the latest version each time you publish.
The older versions don't magically disappear when you publish a new version though. You'll have to remove them manually one way or another:
Can ClickOnce be configured to delete off old published directories?
Actually when u publish only current and previous version source are there in application files,Visual studio publishing tool doesnt delete the older versions in published folder ,so we are seeing too many folders .Just delete everything in publish folder before publsihing and you will have only two folders current and previous version.

Appengine runs a stale version of the code -- and stack traces don't match source code

I have a python27 appengine application. My application generates a 500 error early in the code initialization, and I can inspect the stack trace in the StackDriver debugger in the GCP console.
I've since patched the code, and I've re-deployed under the same service name and version name (i.e. gcloud app deploy --version=SAME). Unfortunately, the old error still comes up, and line numbers in the stack traces reflect the files in the buggy deployment. If I use the code viewer to debug the error, I am however brought to the updated patched code in the online viewer -- and there is a mismatch. It behave as if the app instance is holding on to a previous snapshot of the code.
I'm fuzzy on the freshness and eventual consistency guarantees of GAE. Do I have to wait to get everything to serve the latest deployed version? Can I force it to use the newer code right away?
Things I've tried:
I initially assumed the problem had to do with versioning, i.e. maybe requests being load-balanced between instances with the same version, but each with slightly different code. I'm a bit fuzzy on the actual rules that govern which GAE instance gets chosen for a new request (esp whether GAE tries to reuse previous instances based on a source IP). I'm also fuzzy on whether or not active instances get destroyed right away when different code is redeployed under the same version name.
To take that possibility out of the equation, I tried pushing to a new version name, and then deleting all previous versions (using gcloud app versions list to get the list). But it doesn't help -- I still get stack traces from the old code, despite the source being up to date in the GCP console debugger. Waiting a couple hours doesn't do anything either.
I've tried two things:
disabling and re-enabling the application in GAE->Settings
I'd also noticed that there were some .pyc files uploaded in the snapshot, so I removed those and re-deployed.
I discovered that (1) is a very effective way to stop all running appengine instances. When you deploy a new version of a project, a traffic split is created (i.e. 0% for the old version and 100% for the new), but in my experience old instances might still be running if they've been used recently (despite them being configured to receive 0% of traffic). Toggling kills them all immediately. I unfortunately found that my stale code was still being used after re-enabling.
(2) did the trick. It wasn't obvious that .pyc were being uploaded. I discovered it by looking at GCP->StackDriver->Debug and I saw .pyc files in the tree snapshot.
I had recently updated my .gitignore to ignore locally installed pip runtime dependencies for the project (output of pip install -t lib requirements.txt). I don't want those in git, but they do need to ship as part of my appengine project. I had removed the #!.gitignore special include line from .gcloudignore. However, I forgot to re-add *.pyc into my .gcloudignore.
Another way to see the complete set of files included in an app deployment is to increase the verbosity to info on the gcloud app deploy command -- you see a giant json manifest with checksums. I don't typically leave that on because it's hard to visually inspect, but I would have spotted the .pyc in there.

Google App Engine program Recovery

A friend of mine messed up his php website and accidentally deployed the bad code to the website. Is there a way to recover to the last working deployment instance?
If new code was deployed with a new version number, you may be able to set the previous version as default, if it was not deleted.
If new code was deployed with the same version number, it replaced the previous code - there is no way to restore it.
Typically, version control for your source code takes care of this - you cannot rely on a production environment for restoring previous versions.

How data migration from one table to an other happen in Google app engine

1) Let say I have an application which has to be upgraded to a newer version.
In the newer version data form a table has to be moved to an another table before the application goes live.
How could this be achieved in a Google App Engine?
2) How could I switch over my application from one version to another. I know that GAE supports up to ten version of the same application. But how could I switch over between these versions?
why do you need to move data?
just deploy, give a name to the new version and change the default version to pointing to new one / split the traffic. Why do you need to maintain the old one?

appengine disable app versions

I have a test app on app engine.
I incremented its version and deployed again
now If I modify some data in one version, it is written on datastore that 2nd version uses (because version point to same store)
how can I disable the version, without deleting it?
There's only one datastore that's common to all versions. It's not like each version has its own datastore.
You can set a default version, but you can't prevent anyone from directly forcing a version by going to http://version.appid.appspot.com
you could use namespaces to separate the data between versions.
https://developers.google.com/appengine/docs/python/multitenancy/overview

Resources