"Stackdriver Debugger is not set up for the python runtime on GAE Flex" Warning

1.5k Views Asked by At

I'm attempting to debug a Flask/Python app running on Google Appengine flexible environment.

However, I see a warning message within the Stackdriver Debug interface in Google Console, and am unable to set any breakpoints.

The warning reads:

Stackdriver Debugger is not set up for the python runtime on GAE Flex

Screenshot of warning

Any thoughts on what I'm doing wrong?

I've:

  • Enabled the Stackdriver Debugger API (as mentioned here)
  • Imported and initialised the Debugger (following the instructions here)
  • Included google-python-cloud-debugger in requirements.txt

main.py (the app entry point defined in app.yaml)

from werkzeug.serving import run_simple
from werkzeug.wsgi import DispatcherMiddleware

from wsgi import api, frontend, manage

try:
    import googleclouddebugger
    googleclouddebugger.AttachDebugger()
except ImportError:
    pass

app = DispatcherMiddleware(frontend.create_app(), {
    '/api': api.create_app(),
    '/manage': manage.create_app()
})

if __name__ == '__main__':
    run_simple('0.0.0.0', 5000, app, use_reloader=True, use_debugger=True)

app.yaml

runtime: python
env: flex
entrypoint: gunicorn -b :$PORT main:app

runtime_config:
  python_version: 2

manual_scaling:
  instances: 1

resources:
  cpu: 1
  memory_gb: 0.5
  disk_size_gb: 10

env_variables:
  SQLALCHEMY_DATABASE_URI: "postgresql+psycopg2://myusername:mypassword!@/instancename?host=/cloudsql/instancename"

beta_settings:
  cloud_sql_instances: "instancename"

Update 1

After a comment and noticing a urllib import error, I wondered if the wsgi nature of my application was causing issues. I went back to the documentation, saw a note about Django framework doing something similar and changed the following:

googleclouddebugger.AttachDebugger()

to

googleclouddebugger.enable()

This got rid of the urllib import error, but hasn't resolved the overall issue.

1

There are 1 best solutions below

2
On

I don't see anything wrong with this configuration, but here are some suggestions:

  1. Once you open the GCP Console Debug page, please make sure you selected the correct version of the app from the top dropdown menu before starting the debugging session. It may be pointing to an old app version that is not debuggable, or the page and the dropdown might need a refresh to display the latest version.

  2. Similarly, please check if your Stackdriver stderr logs contains a line that like this:

2017-12-24 15:14:14.000 PST I1224 23:14:14.600462 12 gcp_hub_client.py:335] Debuggee registered successfully, ID: gcp:1025611681465:7144dac417e43025

This means the debugger is actually setup/working properly, and most likely indicates that the UI is requires a refresh or selecting the right app version from the dropdown.

  1. Make sure you have the google-python-cloud-debugger in the requirements.txt file.

  2. Consider adding a simple print statement in the try/except block for the debugger, as folllows:

...
except ImportError as e:
  print 'Failed to import Google Cloud Debugger: %s' % str(e)
  pass

Then, check the stderr logs on Stackdriver Logging to see if this printed any exceptions.

  1. I don't know about werkzeug, but you might want to try disabling the default debugger there by passing use_debugger=False, just to avoid possible conflicts.

  2. Try deploying a simpler flask app (e.g., start with the hello world for Flex from here but modify it to use python_version: 2) and see if the debugger works for you there.