2 Copyright 2020 Canonical Ltd.
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
8 http://www.apache.org/licenses/LICENSE-2.0
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
16 For those usages not covered by the Apache License, Version 2.0 please
17 contact: legal@canonical.com
19 To get in touch with the maintainers, please contact:
20 osm-charmers@lists.launchpad.net
23 # Debugging Charmed OSM
25 This document aims to provide the OSM community an easy way of testing and debugging OSM.
29 - Use upstream published images for debugging: No need to build local images anymore.
30 - Easily configure modules for debugging_mode: `juju config <module> debug_mode=True debug_pubkey="ssh-rsa ..."`.
31 - Debug in K8s: All pods (the debugged ones and the rest) will be running always in K8s.
32 - Seemless setup: VSCode will connect through SSH to the pods.
36 Download the installer:
39 wget http://osm-download.etsi.org/ftp/osm-10.0-ten/install_osm.sh
40 chmod +x install_osm.sh
43 Install OSM from master (tag=testing-daily):
46 ./install_osm.sh -R testing-daily -r testing --charmed
49 Install OSM from a specific tag:
52 ./install_osm.sh -R testing-daily -r testing --charmed --tag <X.Y.Z>
57 Once the Charmed OSM installation has finished, you can select which applications you want to run with the debug mode.
59 - lcm: `juju config lcm debug_mode=True debug_pubkey="ssh-rsa ..."`
60 - mon: `juju config mon debug_mode=True debug_pubkey="ssh-rsa ..."`
61 - nbi: `juju config nbi debug_mode=True debug_pubkey="ssh-rsa ..."`
62 - ro: `juju config ro debug_mode=True debug_pubkey="ssh-rsa ..."`
63 - pol: `juju config pol debug_mode=True debug_pubkey="ssh-rsa ..."`
65 Enabling the debug_mode will put a `sleep infinity` as the entrypoint of the container. That way, we can later connect to the pod through SSH in VSCode, and run the entrypoint of the application from the debugger.
69 Preparing the pods includes setting up the ~/.ssh/config so the VSCode can easily discover which ssh hosts are available
77 > NOTE: The public key that will be used will be `$HOME/.ssh/id_rsa.pub`. If you want to use a different one, add the absolute path to it as a first argument: `./prepare_pods.sh /path/to/key.pub`.
81 In VScode, navigate to [Remote Explorer](https://code.visualstudio.com/docs/remote/ssh#_remember-hosts-and-advanced-settings), and select the pod to which you want to connect.
83 You should be able to see the following hosts in the Remote Explorer:
91 Right click on the host, and "Connect to host in a New Window".
95 The `./prepare_pods.sh` script adds a workspace to the `/root` folder of each pod, with the following name: `<module>.code-workspace`.
97 In the window of the connected host, go to `File/Open Workspace...`. Then select the `<module>.code-workspace` file.
101 Go to extensions and install the Python extension. It will be installed in the remote pod.
103 Now we need to add a [debug configuration](https://code.visualstudio.com/docs/editor/debugging). For that, go to the Run and Debug tab, and click on `create a launch.json file`.
105 Now you will be asked to select a folder in your workspace. Select the folder of the main component:
107 - LCM: select osm_lcm
108 - MON: select osm_mon
109 - NBI: select osm_nbi
110 - RO: select osm_ng_ro
111 - POL: select osm_policy_module
113 Then select `Python` as the environment. And finally, select `Module` and enter the module of the component you are going to test (LCM example: osm_lcm.lcm)