Debugging OpenStack with rpdb

OpenStack has many different code bases.  Figuring out how to run in a debugger can be maddening, especially if you are trying to deal with Eventlet and threading issues.  Adding HTTPD into the mix, as we did for Keystone, makes it even trickier.  Here’s how I’ve been handling things using the remote pythong debugger (rpdb).

rpdb is a remote python debugging tool.  To use it, you edit the python source and add the line

import  rpdb;  rpdb.set_trace()

and execute your program.  The first time that code gets hit, the program will stop on that line, and then open up a socket. You can connect to the socket with:

telnet localhost 4444

You can replace localhost with a ip address or the hostname.

In order to use this from within the unit tests run from tox on keystone client, for example,  you first need to get rpdb into the venv

. .tox/py27/bin/activate
pip install rpdb

Note that if you put the rpdb line into code that is executed on multiple tests, the second and subsequent times tests hit that line of code, the rpdb code will report an error binding to the socket that the address is already in use.

I use emacs, and to run the code such that It matches up with the source in my local git repository, I use:

Meta-X pdb

and then I run pdb like this:

telnet localhost 4444

and gud is happy to treat it like a local pdb session.

One thought on “Debugging OpenStack with rpdb

Leave a Reply

Your email address will not be published. Required fields are marked *