Switching from App Engine Flex to Standard - google-app-engine

I created an App Engine Flex NodeJS app, not realizing that there is no free tier. So I decided to switch to App Engine standard. I updated my app.yaml, deployed, and everything seems to be working. However, I deployed this a couple hours ago, and I still have 2 compute engine instances running. Is there something I need to do to shut those down, or did I just not wait long enough? I don't want them running at all because I don't want to pay for them, especially since the standard app doesn't use compute engine at all.
I tried going to the Compute Engine tab in GCP to see if I could do anything there, but all I get is a "Create instance" button.

Check the Versions page on the Google Cloud Console and make sure that the old version is deleted and that traffic is going to the new version. It may be a good idea to use a new version for the standard env.
Then on the Instances page check if the respective instances are running and shut them down if so.

Related

How to deploy a new version of a Google App Engine production server, without stopping old versions?

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?
Per Google's documentation, when you deploy your code, the default flag of --stop-previous-version is used. This forces the previous version to be stopped. If you do not want that, you should explicitly use the --no-stop-previous-version in your deploy command (we also have this as a feature on our App, a GUI for GAE; you check or uncheck a checkbox).
Unfortunately, Google does not provide a way for the service to automatically shut down later. You'll have to manually shut it down and start the other version later.

How to set my default version in Google App Engine

I'm working on a google app engine app that, after a lot of progress, has multiple versions deployed. I'd really like to switch the default version, which is the very first version of the app, to something more recent, but there doesn't seem to be any way to actually do that.
This article https://gae-php-tips.appspot.com/2013/06/25/harnessing-the-power-of-versions-on-app-engine/ claims there is a "Make Default" button under the version tab, but shows an older version of the console.
In the new version of the development console, there is no such button. This seems like an extremely key feature, and I'm not sure why they've obfuscated it.
Can anyone point me in the right direction?? Thanks!
Currently you can use "Migrate traffic" feature to tell App Engine which version should receive 100% of all requests.
If, at some point, you may want to test a new version, you have an option of splitting all incoming requests between two or more versions of your app.

Can I have two instances on same App Engine project - Java servlet and Endpoints side by side?

We have Java servlets up and running on GAE, using blobstore, datastore and other cloud services.
Currently, we're starting a migration process to cloud Endpoints and we've hit an issue: if we use a different GAE project, we would not be able to query regarding current datastore entities (to the best of my knowledge, Google doesn't want you to do this - see
this question
and the GAE terms of service - section 3.3d), so we need to use the same project for both.
I looked up whether it's possible to have one GAE instance running Java servlets and one instance running Endpoints, but I found no conclusive answer anywhere.
If we try to implement and something goes wrong, we're looking at a potentially major issue for our users, so we need to be sure beforehand.
Has anyone tried something similar, and can assure us that this works?
You have 2 options to run the old and the new code inside the same app (thus with no issues sharing access to the datastore) but as separate engine instances, so they can be developed/deployed/managed independently:
as different versions of the same app/module(s):
the old version remains the default, the new one can be accessed at a different URL during development (possibly via URL routing)
you can use traffic splitting to do live A/B testing on the new code and for gradual final migration until you make the new version the default
as different modules of the same app:
both can run (fully functional) side by side indefinitely, but you need to be more careful during development
traffic is routed to the modules in several possible ways
final migration is done by publishing the new URLs, eventually re-directing the old URLs and finally bringing down the old module code
The 2 approaches can even be combined, if needed, as the final solution described by the OP's in this somehow similar question (for the python environment, but java equivalents exist): Google App Engine upgrading part by part

Google Compute Engine keeps spawning instances, then deploy says no CPU's available

I'm just going through the node.js tutorials with a free trial account, and i'm stuck on the second one where you add a db. I add the mongodb deployment, shows up as a VM instances, fine. And my first deploy worked, but now that i'm trying to edit stuff, my deploy's keep failing.
The error i get is that I've exceeded my CPU quota. Watching the list of VM Instances under Compute Engine, i see it keeps spawning up instances, even though the app isn't being used. Guessing it just spins up 8 instances by default?
But then i guess the build system needs its own VM's, but the CPU capacity is used up, so none available to do subsequent builds?! I feel like i'm missing something...
Also, i see i can explicitly start VM's myself, so what process is creating them form me? And can i turn it off? or set a cap on number of instances it spawns?
Can i tell my project to only use 4
Also, the deploy takes forever, is that normal? Following the tutorials, so far I've only seen this command to deploy:
gcloud preview app deploy app.yaml --set-default
Is there another command that does an incremental deploy or something?
By using gcloud preview app deploy you're actually using Managed VMs which is an App Engine runtime which in turn runs Docker containers on Google Compute Engine, which it creates on its own. In other words, you're not using Google Compute Engine directly.
To get rid of extra VMs, you need to delete old app versions: navigate to Compute > App Engine > Versions and delete the versions you don't want.
See also this answer for more details and suggestions.

How to permanently delete Google managed VMs

I am unable to permanently delete Google App Engine managed VMs I've created. I've deleted them multiple times both from the developer's console and by using the gcloud command. In every case the command completes successfully and the VM is deleted, but then almost immediately Google creates a brand new VM to take its place.
Does anyone know how to permanently delete managed VMs? Thanks.
We are working on improving this experience. For now, though, one workaround is to deploy a non-Managed VM instance as the default version and delete any other versions that are Managed VM-based. Again, this issue is on our radar to be fixed.
[Chris Ramsdale, Product Manager for App Engine]
I wanted to update this post with some of my solutions to deploying (with versions) and deleting instances on Google Compute Engine's managed VMs. Here's a solution I found for deleting the default GCE managed VM:
Make sure you have the up-to-date GCE components. Run gcloud components update in the Google Cloud SDK Shell.
In your app.yaml, remove the vm:true, resources: section, and manual scaling: section.
Navigate to Compute -> App Engine -> Versions and record the <default-version-number>. Mine looks like 20150722t1245032 with the words (default) indicating the default version.
Deploy the application, set the default, and specify the default version. gcloud preview app deploy "...\app.yaml" --set-default --version=<default-version-number>.
Navigate to Compute -> Compute Engine -> VM instances. Select the default instance and delete.
I was also taught how to stop deploying additional instances:
The key is to specify the version number gcloud preview app deploy "...\app.yaml" --set-default --version=<version-number>. #ZacharyNewman was able to help me with this problem.
And finally, this is how to delete the additional versions of an instance:
Navigate to Compute -> App Engine -> Versions and delete the versions you don't want.
Navigate to Compute -> Compute Engine -> VM instances. Select the instances you don't want and delete.
Hope this helps!
There might be a simpler way to explain this -- "basically, you cannot delete a version that's receiving 100% of the traffic."
Therefore, you just need to create a non managed VM, like a simple helloworld application. Then, you can move all of the traffic to this helloworld application (see graphic, I named mine version 0), then, delete version 20160... or whatever the name of your vm is.
At some point in time, you're probably going to experiment or spin up your managed VM again. When you do that, it will automatically start getting 100% of the traffic.
Or, if you happen to know version number receiving 100% of the traffic, you can always deploy a simple, non managed VM, with this version.
In Google Cloud Console under App Engine -> Versions , select the default version of your managed VM application and use STOP button to turn it off.
I ran into the same problem this is how i was able to stop the managed VM permanently. Just go to appengine -> settings -> disable application. This will automatically stop and delete your VM. In future if you want to run managed vm just enable application this will redeploy your application to the last known version.

Resources