Jump to: navigation, search

Manila/Debugging

< Manila
Revision as of 19:43, 24 June 2014 by Clinton Knight (talk | contribs) (Remote debugging)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

With the proposed changes in Manila, setting up source-level debugging should be straightforward. This page describes the process for PyCharm; feel free to enhance the content with other IDEs such as Eclipse/PyDev.

Design

A few components are needed:

  1. Changes to the manila/bin scripts (manila-api, manila-scheduler, manila-share) that start the individual manila services to prevent eventlet.monkey_patch() from patching the thread library if debugging is active. The patching code is called slightly later in the startup sequence to allow the config options to be processed, lest we not know if debugging is active.
  2. Two new CLI options, pydev-debug-host and pydev-debug-port, to specify debugger connections. These options are consistent with Keystone, though other OS projects differ in their names for these :-/ A third debug option, standard-threads, is available free from Keystone that prevents thread library patching but doesn't initiate a debugger connection.
  3. Insertion of the debugger connection code in the service Launcher class.

Setup

Remote debugging

1. Ensure your OpenStack and PyCharm environments have the pydevd library installed. This is distributed as an egg in the top level of the PyCharm installation directory; there are two separate eggs for Python 2.x and 3.x. For Python 2, just run "easy_install pycharm-debug.egg" to install it in your Python path.

Pydevd.png


2. Create a remote debug configuration in PyCharm (Run-->Edit Configurations...-->Python Remote Debug). If the code on the OpenStack and PyCharm hosts is on different paths (likely), define a path mapping in the remote debug configuration.

Manila debug remote.png


3. Invoke the debug configuration (Run-->Debug...-->(config name)). PyCharm will begin listening on the specified port.

4. Start the Manila service to be debugged using the pydev-debug-host switch, where the host is the system running PyCharm. If the default port (58786) isn't suitable, specify a different port using the pydev-debug-port switch.

Start remote debug


5. The service will connect to PyCharm, at which point remote debugging is active.

Manila debug remote active.png


Local debugging

1. If PyCharm is running locally to OpenStack, local debugging is especially convenient. Install the pydevd egg as described above.

2. Create a local config.

Local debug config


3. Invoke the debug configuration, which will start the relevant Manila service and route is console output to PyCharm.