How to enable cloud debugger for python flask app on Cloud Run

535 Views Asked by At

I am trying to enable Google Cloud Debugger for a Flask app that I am running in Cloud Run.

The project is a simple "Hello World" with Flask and Dockerfile. The code is synced for Bitbucket to Cloud Source Repositories and set to trigger launch on master branch update.

Everything is working as expected, with new pushes triggering a successful build. Now, though, I want to add Cloud Debugger and have hit some problems.

Following the documentation, I have:

  • Enabled Cloud Debugger API
  • Added pip install google-python-cloud-debuggerto my Dockerfile
  • Added the following code early in my application
try:
  import googleclouddebugger
  googleclouddebugger.enable(
    breakpoint_enable_canary=True
  )

except ImportError:
  pass

I pushed the changes and the build was successful.

I can see that the Cloud Repository is showing the right commit, but when I look under debugger, no applications are visible (screen shot 1 below) and if I click "start debugging" in Cloud Source Repo, I get a message saying that I need to setup Debugger (screenshot 2)

Can anyone tell me what I am missing?

enter image description here

enter image description here

1

There are 1 best solutions below

4
On

Check if you have the Service account credentials file in your application folder:

  1. Create a credentials file
  2. Delete your application from the Cloud Run Console
  3. Redeploy your app to the Cloud Run
  4. If you followed the steps properly, your application should show up on the Debugger page.

The possible cause of the issue is that your app can't communicate with your GCP project due to the lack of authentication.

If it doesn't work, use the link to the application logs that's being provided when deploying the app, and share the logs with the error.