GAE Doesn't Deploy Latest Code - python

GAE will not update the deployed code through gcloud. For instance, I created this method:
main.py
#app.route('/test',methods=['GET'])
def test():
print 'print test'
return 'test'
app.yaml
runtime: python27
api_version: 1
threadsafe: true
runtime_config:
python_version: 2
instance_class: F2
handlers:
- url: /.*
script: main.app
libraries:
- name: flask
version: 0.12
deploy the app:
gcloud app deploy app.yaml queue.yaml --project $PROJECT
Then I get a 404 when visiting /test.
I tracked down the log error:
This request caused a new process to be started for your application,
and thus caused your application code to be loaded for the first time.
This request may thus take longer and use more CPU than a typical
request for your application.
I looked at this article, which noted that I shouldn't be getting the error every time I visit the URL. I do.
I added --verbosity=info to my deployment and everything looked great except:
INFO: Could not find any remote repositories associated with
[path-to-app]. Cloud diagnostic tools may not be able to display the
correct source code for this deployment.
The code appeared updated in the dedugger, which is strange. The latest version is 100% deployed in the App Engine Dashboard.
This is really confusing because on deployment, there isn't a repo, but the code appears in the debugger but the end point won't function because there aren't enough resources.
There seems to be a lot happening here and not sure what the issue is.
Update
Some posts recommend a warmup. I followed the guidelines here and still, no dice. I'm getting a 404 when visiting /test and /_ah/warmup.

This issue could be caused by multiple different reasons, there could be a lot of factors in play, in most cases the error 404 shows when the app.yaml failed to allocate the flask library as the ‘flask’ libraries by default not bundled in the libraries the Google App Engine includes. So it needs to be added manually. One of the way to figure out if the issue is a deployment issue is to go to this link (https://console.cloud.google.com/logs/viewer) and check if there is any logs recorded or not. If there is no log appearing in the viewer it could very well mean that the problem occurred even before it actually knocks the server.
Additionally, I would highly recommend you to go through the following link (https://codelabs.developers.google.com/codelabs/cloud-vision-app-engine/index.html?index=..%2F..%2Findex#0) to deploy flask on the Google Cloud App Engine environment.
Also, I would like to make a suggestion to try a workaround using the ‘webapp2’ library if possible. The link is the following (http://webapp2.readthedocs.io/en/latest/index.html)
I have also noticed there is an attempt to run the queue.yaml. It is important to configure the file accordingly as well.
To summarize, I would really appreciate if you could try all the different possibilities to deploy the flask library and observe the results. Thank you so much.

Related

Deploying App on Google App Engine - Error Response: [13] An internal Error occurred

I am trying to deploy a python app on google app engine.
I was able to preview the web successfully on cloud shell editor but when I deploy it, I obtain Error Response:[13] An internal error occurred.
This is my app.yaml content
runtime: python
env: flex
entrypoint: gunicorn -b:8078 main:app
runtime_config:
python_version: 3.7
manual_scaling:
instances: 2
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10
It doesn't also show logs that could indicate what is wrong with the application.
Thank you
There have been multiple iterations since the original question was asked. OP has switched from standard to flex and python27 to python37.
I think I've previously come across someone who encountered the error because they had exceeded the 1000 file limit. Since you're using python37, I assume you have a virtual environment in your project folder which you first used in running the App on your local machine. You need to have a skip_files section in your app.yaml or a .git_ignore or .gcloudignore folder and include your virtual env in it so that gcloud doesn't try to deploy it
You can also check out these other links to see if they can help you resolve your issue
https://github.com/GoogleCloudPlatform/nodejs-getting-started/issues/172
https://groups.google.com/g/google-appengine/c/M4acI1YElVs
If none of the above, I'm not sure one can figure out the solution without looking at the code. If your code is public, you can provide a link to the github.

Google App Engine Resource Error on the Django Deployment Tutorial

I have been looking for a great way to deploy my Django application and I found Google App Engine Flex a pretty good solution. I have not much experience in application deployment so I follow along with the Official Google Tutorial about the deployment.
On the last step, the tutorial instructs me to deploy the application within the cmd prompt: gcloud app deploy.
I follow along. Everything seems fine until I get this message:
Updating service [default] (this may take several minutes)...
After a while I get this message:
Updating service [default] (this may take several minutes)...failed.
ERROR: (gcloud.app.deploy) Error Response: [13] Flex operation <stuff..> error [INTERNAL]: An internal error occurred while processing task /app-engine-flex/insert_flex_deployment/flex_create_resources>2020-10-10T07:36:04.734Z7747.ue.0: Deployment Manager operation <stuff..> errors: [code: "RESOURCE_ERROR"
location: "<stuff...>"
message: "{\"ResourceType\":\"compute.beta.regionAutoscaler\",\"ResourceErrorCode\":\"403\",\"ResourceErrorMessage\":{\"code\":403,\"message\":\"The caller does not have permission\",\"status\":\"PERMISSION_DENIED\",\"statusMessage\":\"Forbidden\",\"requestPath\":\"<stuff..>",\"httpMethod\":\"POST\"}}"
]
Every time I rerun the command gcloud app deploy I get the exact same error. Any idea how to fix that? Google Search doesn't reveal anything for me.
Firstly try and give the following permissions to yourself. This answer will help with some of the explanations.
Also, try and add the following in your .yaml file and see if it solves it
automatic_scaling:
min_num_instances: 1
max_num_instances: 7

Server Error 500 When Using gcloud to deploy my Python Web App

After following freecampcode's web application tutorial, creating my own Google Cloud SDK project and deploying my sample social network website using Python and Flask (which I found mostly thought this tutorial), I am getting this same error: Internal/Unknown Server Error 500, which looks like:
Error: Server Error
The server encountered an error and could not complete your request.
Please try again in 30 seconds.
Checking the logs, I get the errors:
-2020-07-06 01:51:29 default[20200705t214944] "GET / HTTP/1.1" 500
-2020-07-06 01:51:32 default[20200705t214944] "GET /favicon.ico HTTP/1.1" 500
Any help would be greatly appreciated. I've been stuck on this issue for a while. If you need additional information on the project, please let me know. This is my first gcloud project.
EDIT: I checked the error logs and saw the error:
ImportError: No module named main
at LoadObject (/base/alloc/tmpfs/dynamic_runtimes/python27g/174489198b39d9fb/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py:85)
at _LoadHandler (/base/alloc/tmpfs/dynamic_runtimes/python27g/174489198b39d9fb/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py:311)
at Handle (/base/alloc/tmpfs/dynamic_runtimes/python27g/174489198b39d9fb/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py:240)
So I added the file main.py with the contents:
from app.wsgi import main as app
entrypoint: gunicorn -b :$PORT app.wsgi:main
and I still get the same internal error.
What I noticed is that tutorial 1 (this one) contain how-to for python2, while the 2nd tutorial (this one) is how-to build with python3.
What more python2 not supported any more, so there is no point to learn how to use it. Here it is the reference.
I suppose you have to change environment in app.yaml file. Here is reference to python3 environment. I would start with that.
What I recommend you as well is to go to Google Cloud Platform and open App Engine (direct link). On the right you have a possibility to go with tutorial called "App Engine Quickstart" or "Hello World". You can choose Python and go trough whole process of creating HelloWorld app, which by the way is Flask as well. I would try it even before the once you are trying.
I hope it will help!
one way is to Try with DEBUG mode off
still if it not works then try this below way with this you will get exact details why you got this error
Try this it will return exact error
#app.errorhandler(500)
def internal_server_error(e):
return jsonify(error=str(e)), 500

AppEngine warning - OpenBLAS WARNING - could not determine the L2 cache size on this system

I try to deploy application on the GC AppEngine. There are no errors during deploy process but application doesn't work (Just show loading page).
The only one strange raw in logs
OpenBLAS WARNING - could not determine the L2 cache size on this system
By the way - it works well on my local machine.
This is python web app based on Dash framework
My app.yaml:
runtime: python37
service: service-name
instance_class: F2
entrypoint: gunicorn -b :$PORT main:app.server
Requirements.txt:
Flask==1.0.2
dash==0.34.0
dash-html-components==0.13.4
dash-core-components==0.41.0
dash-table==3.1.11
gunicorn==19.9.0
google-cloud-pubsub==0.37.2
requests==2.21.0
pandas==0.23.4
I just had your same problem with pandas and Dash and found your question (hoping it would give me some light). After being stuck for several hours, I found the answer, and came back to share :-)
If the only error that you're seeing is the OpenBLAS warning, most likely the app is working well. After debugging this problem for several hours, I found that as Dash and Pandas consume a lot of memory, the F2 instance is not able to handle the web app properly and fails due to lack of RAM memory. Please try changing in your YAML/JSON configuration file your instance to the highest possible automatic unit with more RAM memory, and then it will probably work:
instance_class: F4_HIGHMEM
EDIT: Google App Engine now supports more instance types. Check the docs of instance types: standard instances
In addition, please keep in mind that the first time you run this web app, it will take considerably more time to execute. If you check the logs you'll have several prompts like the one below. Just wait a little bit more
This request caused a new process to be started for your application,
and thus caused your application code to be loaded for the first time.
This request may thus take longer and use more CPU than a typical
request for your application.
I personally solved it by adding a timeout to gunicorn, as the default timeout is only 30 sec
entrypoint: gunicorn -b :$PORT main:app.server --timeout 120
I found this solution as I tried the following:
switched from a F1 to a F4_1G instance: still had the same warning
switched from App Engine Standard to App Engine Flexible environment (which I highly DO NOT recommend, as app engine flexible instances not properly shut down (deleted) can cost you a lot of money: please see here for reference Pricing of Google App Engine Flexible env, a $500 lesson), with 16gb of ram and 4 CPU -> eventually got a different warning "[CRITICAL] WORKER TIMEOUT" which pointed me to this post: Gunicorn worker timeout error , which is where I found this solution.
Now my app works well, even with a F1 instance 😊
Don't forget to change the number of workers !
there is a default number of workers in AppEngine instances, so your application is multiplied by this number on the same instance
https://cloud.google.com/appengine/docs/standard/python3/runtime
I experienced the same error log using a AWS Lambda function. My function was processing a decent number of records so I needed to increase two settings in my lambda function configuration:
Increase the size of Memory.
Increase the Timeout in seconds.
Hope that helps.

Can Google Cloud Endpoints run in a App Engine Module?

dear all
I'm trying to create a App Engine Module for hosting my api server developed with Google Cloud Endpoints. The endpoint I developed runs well in local dev environment but it responds notFound error after I deployed to remote and test it. I was guessing this might be caused by the fact that endpoints are run in a non-default module. Not sure though. Here is my module definition file (api-server.yaml):
application: myapp
module: api-server
version: dev
runtime: python27
instance_class: F2
api_version: 1
threadsafe: true
automatic_scaling:
max_idle_instances: 5
handlers:
- url: /_ah/spi/.*
script: api_dispatch.application
libraries:
- name: endpoints
version: 1.0
I plan to host endpoints with module cause my api server actually share a lot of code with my default module, which is a normal web app. Please let me know if it's possible. And sample code is very welcome.
Thanks a lot!
Yes, it's supported. I don't know why the problem happened before. But it starts working now.

Categories

Resources