Friday, December 13, 2013

Debugging Nova using a remote debugger

You can use a remote debugger to attach to nova services by specifying the host and port as command line arguments. For example

/usr/local/bin/nova-compute --config-file /etc/nova/nova.conf --remote_debug-host 172.16.245.1 --remote_debug-port 1234
In order to do this you need to have a remote debug server - this wiki describes how to use remote debugging with pycharm. You need a commercial license to do remote debugging with pycharm.

Preparing the Server


Start pycharm and create a remote debug runtime configuration. Change the host and port to your IP address and the port you want to use. The path map shows how to translate the path in your nova environment to the path that your debug server understands. The example here shows /opt/stack/nova mapped to /Volume/OpenStack/nova. I have used samba to mount my /opt/stack directory on my debug host at mount point /Volume/Openstack. You need this or you will not be able to see your code and set breakpoints. 



Once you have a remote debug configuration, press the Bug to start debugging.


You should then see the debugger waiting for connection....



Preparing the client


You need to prepare your environment where you run nova (remote host) to connect to the debug server.  


First you need to copy the pydev package from your pycharm installation to your remote host.  The file is called pycharm-debug.egg and it is located in the root directory of your pycharm installation.  Copy that to your remote host and add it to your python path.  

Debugging

With your debug server running, start your nova service.  For example:

/usr/local/bin/nova-compute --config-file /etc/nova/nova.conf --remote_debug-host 172.16.245.1 --remote_debug-port 1234

You should see the debugger connect in the console window.  You can now set breakpoints, examine variables, etc.   Note that when you are doing remote debugging, you are changing the way that Nova uses the eventlet library to support async IO.  So you may see things that do not occur without remote debugging.  Still i find it'a very handy to use and have not had any unexpected results.

Happy Debugging!

More information

For pycharm - http://blog.jetbrains.com/pycharm/2010/12/python-remote-debug-with-pycharm/
For Eclipse - http://pydev.org/manual_adv_remote_debugger.html

No comments:

Post a Comment