Sean Dague | bd6614a | 2016-08-11 09:05:16 -0400 | [diff] [blame] | 1 | ========================== |
| 2 | Developing with Devstack |
| 3 | ========================== |
| 4 | |
| 5 | Now that you have your nifty DevStack up and running, what can you do |
| 6 | with it? |
| 7 | |
| 8 | Inspecting Services |
| 9 | =================== |
| 10 | |
| 11 | By default most services in DevStack are running in a `screen |
| 12 | <https://www.gnu.org/software/screen/manual/screen.html>`_ |
| 13 | session. |
| 14 | |
| 15 | .. code-block:: bash |
| 16 | |
| 17 | os3:~> screen -list |
| 18 | There is a screen on: |
| 19 | 28994.stack (08/10/2016 09:01:33 PM) (Detached) |
| 20 | 1 Socket in /var/run/screen/S-sdague. |
| 21 | |
| 22 | You can attach to this screen session using ``screen -r`` which gives |
| 23 | you a view of the services in action. |
| 24 | |
| 25 | .. image:: assets/images/screen_session_1.png |
| 26 | :width: 100% |
| 27 | |
| 28 | Basic Screen Commands |
| 29 | --------------------- |
| 30 | |
| 31 | The following minimal commands will be useful to using screen: |
| 32 | |
| 33 | * ``ctrl-a n`` - go to next window. Next is assumed to be right of |
| 34 | current window. |
| 35 | * ``ctrl-a p`` - go to previous window. Previous is assumed to be left |
| 36 | of current window. |
| 37 | * ``ctrl-a [`` - entry copy/scrollback mode. This allows you to |
| 38 | navigate back through the logs with the up arrow. |
| 39 | * ``ctrl-a d`` - detach from screen. Gets you back to a normal |
| 40 | terminal, while leaving everything running. |
| 41 | |
| 42 | For more about using screen, see the excellent `screen manual |
| 43 | <https://www.gnu.org/software/screen/manual/screen.html>`_. |
| 44 | |
| 45 | Patching a Service |
| 46 | ================== |
| 47 | |
| 48 | If you want to make a quick change to a running service the easiest |
| 49 | way to do this is: |
| 50 | |
| 51 | * attach to screen |
| 52 | * navigate to the window in question |
| 53 | * ``ctrl-c`` to kill the service |
| 54 | * make appropriate changes to the code |
| 55 | * ``up arrow`` in the screen window to display the command used to run |
| 56 | that service |
| 57 | * ``enter`` to restart the service |
| 58 | |
| 59 | This works for services, except those running under Apache (currently |
| 60 | just ``keystone`` by default). |
| 61 | |
| 62 | .. warning:: |
| 63 | |
| 64 | All changes you are making are in checked out git trees that |
| 65 | DevStack thinks it has full control over. Uncommitted work, or |
| 66 | work committed to the master branch, may be overwritten during |
| 67 | subsequent DevStack runs. |
| 68 | |
| 69 | Testing a Patch Series |
| 70 | ====================== |
| 71 | |
| 72 | When testing a larger set of patches, or patches that will impact more |
| 73 | than one service within a project, it is often less confusing to use |
| 74 | custom git locations, and make all your changes in a dedicated git |
| 75 | tree. |
| 76 | |
| 77 | In your ``local.conf`` you can add ``**_REPO``, ``**_BRANCH`` for most projects |
| 78 | to use a custom git tree instead of the default upstream ones. |
| 79 | |
| 80 | For instance: |
| 81 | |
| 82 | .. code-block:: bash |
| 83 | |
| 84 | [[local|localrc]] |
| 85 | NOVA_REPO=/home/sdague/nova |
| 86 | NOVA_BRANCH=fold_disk_config |
| 87 | |
| 88 | Will use a custom git tree and branch when doing any devstack |
| 89 | operations, such as ``stack.sh``. |
| 90 | |
| 91 | When testing complicated changes committing to these trees, then doing |
| 92 | ``./unstack.sh && ./stack.sh`` is often a valuable way to |
| 93 | iterate. This does take longer per iteration than direct patching, as |
| 94 | the whole devstack needs to rebuild. |
| 95 | |
| 96 | You can use this same approach to test patches that are up for review |
| 97 | in gerrit by using the ref name that gerrit assigns to each change. |
| 98 | |
| 99 | .. code-block:: bash |
| 100 | |
| 101 | [[local|localrc]] |
| 102 | NOVA_BRANCH=refs/changes/10/353710/1 |
| 103 | |
| 104 | |
| 105 | Testing Changes to Apache Based Services |
| 106 | ======================================== |
| 107 | |
| 108 | When testing changes to Apache based services, such as ``keystone``, |
| 109 | you can either use the Testing a Patch Series approach above, or make |
| 110 | changes in the code tree and issue an apache restart. |
| 111 | |
| 112 | |
| 113 | Testing Changes to Libraries |
| 114 | ============================ |
| 115 | |
| 116 | When testing changes to libraries consumed by OpenStack services (such |
| 117 | as oslo or any of the python-fooclient libraries) things are a little |
| 118 | more complicated. By default we only test with released versions of |
| 119 | these libraries that are on pypi. |
| 120 | |
| 121 | You must first override this with the setting ``LIBS_FROM_GIT``. This |
| 122 | will enable your DevStack with the git version of that library instead |
| 123 | of the released version. |
| 124 | |
| 125 | After that point you can also specify ``**_REPO``, ``**_BRANCH`` to use |
| 126 | your changes instead of just upstream master. |
| 127 | |
| 128 | .. code-block:: bash |
| 129 | |
| 130 | [[local|localrc]] |
| 131 | LIBS_FROM_GIT=oslo.policy |
| 132 | OSLOPOLICY_REPO=/home/sdague/oslo.policy |
| 133 | OSLOPOLICY_BRANCH=better_exception |
| 134 | |
| 135 | Because libraries are used by many services, library changes really |
| 136 | need to go through a full ``./unstack.sh && ./stack.sh`` to see your |
| 137 | changes in action. |
| 138 | |
| 139 | To figure out the repo / branch names for every library that's |
| 140 | supported, you'll need to read the devstack source. |