1

As announced today in Production Troubleshooting with Cloud Debugger now available for Python, supposedly I can use Python Debugger now.

I am running AppEngine Managed VMs on GCE images, so am following the guide for Setting up Python on Compute Engine. I have modified my Dockerfile to add pip install google-python-cloud-debugger (I've also tried installing the library directly into my app/lib, which is included in my sys.path):

FROM gcr.io/google_appengine/python-compat
RUN pip install google-python-cloud-debugger
ADD . /app

And then I have modified my main.py to enable the debugger:

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

Unfortunately, when I commit the code, run gcloud preview app gen-repo-info-file, and push it, I cannot use the debugger. When I go to https://console.developers.google.com/debug, it loads my github repository on the right, but I see an error message in the left-hand nav area:

Debugging is not available. You can debug Java applications running on App Engine or Compute Engine

Any ideas what might be going wrong, or how to debug the debugger?

Mike Lambert
  • 1,976
  • 1
  • 17
  • 31

3 Answers3

1

Although the other thread did provide a lot of opportunity to follow common best-practices in debugging, the solution is a lot simpler than either of us had imagined. It's likely that the errors you're seeing are a result of the fact that Managed VMs with python is not yet a supported platform for Cloud Debugger, according to the documentation.

However, with the growth of the Cloud Debugger service, and the fact that Cloud Debugger with python at all was just announced on the 7th, it's certainly possible that this will change.

Feel free to file Feature Requests in the Cloud Platform Public Issue Tracker if you notice something missing and would like to let us know that it's an interest to you and others who might star the issue.

Nick
  • 3,581
  • 1
  • 14
  • 36
  • 1
    Ahhh, I had thought "Any Python application running on a Google Compute Engine instance" captured the "A Python Managed VM application running on a GCE instance" case, but looking at the Java supported platforms makes it clearer that Managed VMs are not supported yet. Thanks! – Mike Lambert Dec 10 '15 at 19:41
  • So http://googlecloudplatform.blogspot.tw/2016/02/diagnose-problems-in-your-production-apps-faster-with-Google-Cloud-Debugger.html mentions: "With this release, Cloud Debugger is now available for the following languages and platforms: Python applications running on App Engine, App Engine Managed VMs and Compute Engine" However, I can't get the debugger to find a debuggable app, and the official docs at https://cloud.google.com/debugger/ still say "Python App Engine applications running on App Engine." (and don't mention Managed VMs). So...I assume the blog post is wrong? – Mike Lambert Mar 02 '16 at 09:36
0

EDIT: Although this answer's thread contains useful debugging steps, the root cause of the issue is explained in my other posted answer.

It's likely two things are happening here:

The first is that your pip command, running as a normal user, wants to access the system install location and fails without root privileges. Try sudo pip install... or pip install -t lib/ google-python-cloud-debugger.

The second thing that's happening is that your code is catching an ImportError and merely passing. I've seen that construction before in my life as a python-speaker, and honestly it's a foot-shotgun if I ever saw one. What purpose could pass serve? An error log quickly shows the issue if you take such a precaution.

Nick
  • 3,581
  • 1
  • 14
  • 36
  • I was following the Google documentation above verbatim, for the two issues you mentioned. (The non-sudo pip, and the quiet-pass.) So perhaps it's worth telling the doc-writer to fix that doc too? For the quiet-pass, I've added a logging statement, but I have no idea where I'd see it. It wouldn't be in a per-servlet log (since it is before the wsgi server initializes), and it's not in the VM instance's serial console output. There are other logs in my main.py that I never see in prod either. – Mike Lambert Dec 08 '15 at 22:08
  • As far as the pip, I have tried installing googleclouddebugger library into a lib/ that I push, as mentioned in my original question. It doesn't work, but perhaps it's making more progress? It appears like every request immediately 500s (without any log output whatsoever). The "/mapreduce/controller_callback" requests return 200, but they are routing through a different wsgi server / module via my app.yaml, so I'm not sure how relevant that is. And if I open the Cloud Debugger while my app is serving straight 500s, it continues to tell me the same error message: "Debugging is not available" – Mike Lambert Dec 08 '15 at 22:14
  • You'll need to add `lib/` to your python path if using such a folder. Did `sudo` not help to make the module globally-visible? – Nick Dec 08 '15 at 22:28
  • I installed it into a pushed lib/ directory that already had other libraries I successfully use (i.e., it's in my path already). I'm fine with this approach, so I never tried sudo. And the fact that the behavior changes now with 500s, after being loaded from lib/ , I assume it's correctly being found in lib/, and there is no particular reason to try sudo...? – Mike Lambert Dec 08 '15 at 22:44
  • Why are the 500s served? There ought be logs somewhere. Can you inspect the GCE instance hosting the Docker process itself? – Nick Dec 08 '15 at 23:20
  • Logs would certainly be nice! :) From the web console, I can only see the per-servlet logs (where each servlet is empty) and the serial console log (nothing relevant). I just logged into the GCE and poked around all over the disk looking for logs (either explaining the 500s, or something at startup relating to the googleclouddebugger import), but couldn't find anything. Any suggestions? – Mike Lambert Dec 09 '15 at 02:33
  • Having searched the GCE instance hosting docker, you could check the docker containers themselves (in `/var/log`), since this is where the request and error logs lie for your app, nginx proxy, &c. However, it would be an error if request logs serving 500 were visible there and not in the proper view of the Developers Console. If the container logs turn up nothing, the 500s could be infrastructural, or you're in the wrong instance... – Nick Dec 09 '15 at 18:42
  • Did you check the response headers on the 500 and determined that it reached your containerized application? – Nick Dec 09 '15 at 18:43
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/97442/discussion-between-mike-lambert-and-nick). – Mike Lambert Dec 09 '15 at 19:30
  • I would love to figure out what's going on there. Please send mail to cdbg-feedback@google.com so that we can engage directly. – Vlad Lifliand Jan 04 '16 at 22:28
0

The easiest way to check that the Python Cloud Debugger is properly installed is to try importing it in Python interactive console:

docker run -i -t cdbgtest bin/bash
python
import googleclouddebugger
print googleclouddebugger.__version__

My guess is that in your case pip install google-python-cloud-debugger fails. If that's the case, it's probably due to outdated pip. Installing pip with sudo easy_install pip would solve it.

Vlad Lifliand
  • 470
  • 2
  • 5