1

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

Alex Waygood
  • 6,304
  • 3
  • 24
  • 46
Finglish
  • 9,692
  • 14
  • 70
  • 114
  • which version of python you have? which cloud debugger version you have installed? – Pentium10 Sep 24 '21 at 09:45
  • Did you deployed the `source-context.json` file https://cloud.google.com/debugger/docs/source-context#python – Pentium10 Sep 24 '21 at 09:47
  • what distro is your dockerfile using? alpine is listed as trouble on git for python-debugger. – Pentium10 Sep 24 '21 at 09:51
  • @Pentium10. Thank you such clear comments. I have python 3.7 running at the moment. I downgraded from 3.9 as I found conflicting advice on what was needed. I am using the Slim distro. I haven't deployed the source-context.json file, as this was not mentioned in relation to Cloud Run, but I will give that a try next. – Finglish Sep 24 '21 at 11:24
  • @Pentium10 Adding the source-context.json didn't help. Maybe I will try a different distro next...Do you have any recommendations? – Finglish Sep 24 '21 at 13:22

1 Answers1

0

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.

Farid Shumbar
  • 1,360
  • 3
  • 10
  • I believe this is the issue. But I am not sure how best to update. When developing locally I have been using "gcloud auth application-default login". to authorise temporarily with my own credentials. – Finglish Sep 25 '21 at 03:12
  • Works locally, but whe pushed ot Cloud run I get access permisson issues: Permission 'cloudbuild.builds.create' denied on .... – Finglish Sep 25 '21 at 03:26
  • @Finglish I'm not sure if you tried with the credentials file as initially, I was receiving the same error but adding the file fixed it – Farid Shumbar Sep 27 '21 at 09:13
  • I fixed the cloudbuild issue, it was unrelated. I am going to try adding the credentials file, but I am not keen on doing it this way in the long run as storing an unencrypted key file with the code seems like a bad idea. – Finglish Sep 27 '21 at 20:54