2

I am trying to deploy a python application and I am receiving the following error message:

ERROR: (gcloud.app.deploy) Error Response: [4] Your deployment has failed to become healthy in the allotted time and therefore was rolled back. If you believe this was an error, try adjusting the 'app_start_timeout_sec' setting in the 'readiness_check' section.

My app.yaml is:

runtime: python
runtime_config:
  python_version: 3
env: flex
service: newservice
handlers:
- url: /
  script: hello.py

manual_scaling:
  instances: 1
resources:
  cpu: 1
  memory_gb: 0.5
  disk_size_gb: 10

I believe the problem is related to the yaml file, since I have deployed a sample application previously with no problems (using entrypoint on my yaml), then when I added a new python script and referred to it on the yaml file (using the handlers, to run my message block) I started to get this error.

Edit: after GAEFan's answer my hello has included a handler for readiness_check as:

def post():
    self.response.headers['Content-Type'] = 'application/json'   
    obj = {
      'status': 200, 
    } 
    self.response.out.write(json.dumps(obj))

webapp2.WSGIApplication([
    ('/readiness_check', post())
], debug=True)
guerreiro
  • 93
  • 1
  • 12

2 Answers2

3

Readiness checks are enabled by default. So, you should set up url handlers for them. In this case, GAE is sending a request to /readiness_check, but your app.yaml doesn't have a handler for that url. Try this:

handlers:
- url: /.*
  script: hello.py

And make sure the url returns a 200 or similar response. To customize the readiness checking:

readiness_check:
  path: "/readiness_check"
  check_interval_sec: 5
  timeout_sec: 4
  failure_threshold: 2
  success_threshold: 2
  app_start_timeout_sec: 300

Or:

liveness_check:
  path: "/liveness_check"
  check_interval_sec: 30
  timeout_sec: 4
  failure_threshold: 2
  success_threshold: 2

Details at: https://cloud.google.com/appengine/docs/flexible/custom-runtimes/configuring-your-app-with-app-yaml#legacy_health_checks

GAEfan
  • 11,244
  • 2
  • 17
  • 33
  • Thank you for pointing it out. I still did not have success. I have both url: / and url: /.* and tried it with both readiness and liveness checks. I might not have told you that my deploy keeps "Updating service" and after a long time I receive the above message, so I think I am not be able to receive the 200 status, if ii is possible, how can I do it? – guerreiro Jul 03 '18 at 16:33
  • in `hello.py`, do you have a url handler for `/readiness_check`? Can you test locally? – GAEfan Jul 03 '18 at 16:47
  • I am new to this. Does this handler make sense? (yes, my hello works locally) def post(): self.response.headers['Content-Type'] = 'application/json' obj = { 'status': 200, } self.response.out.write(json.dumps(obj)) webapp2.WSGIApplication([ ('/readiness_check', post()) ], debug=True) – guerreiro Jul 03 '18 at 17:15
  • I've edited my question to include my supposed handler for better read – guerreiro Jul 03 '18 at 17:27
  • Actually now I am receiving the error: "Timed out waiting for the flex deployment to become network provisioned." – guerreiro Jul 03 '18 at 17:56
1

You're running in a flexible environment app, the handlers configuration is a standard environment one. You need to use the entrypoint configuration for the flexible environment. From Application startup:

The runtime starts your application using the entrypoint defined in app.yaml. The entrypoint should start a process that responds to HTTP requests on the port defined by the environment variable PORT.

Without it your app is not really working and can't serve the health check requests.

Maybe useful: How to tell if a Google App Engine documentation page applies to the standard or the flexible environment

Dan Cornilescu
  • 39,470
  • 12
  • 57
  • 97