Python Debugging
Raftt supports interactive Python debugging using JetBrains IDEs and VS Code.
To debug with Raftt, you must first install Raftt's IDE plugin. See here for installation instructions.
Configuration
The configuration differs between different IDEs.
- JetBrains IDEs
- VS Code
To debug with Raftt, start by defining a "standard" debug configuration, as if you would debug the process locally. For help creating such a configuration, see JetBrains docs.
Then, you only need to add a single env var called RAFTT_WORKLOAD
stating the workload to debug. For example, here you can see the configuration for debugging the recommendations
service, as a part of our tutorial -
Debugging a sidecar container
To debug a sidecar container, add an additional env var - RAFTT_CONTAINER
, whose value is the debugged container name. If not stated, the selected container is the workload's main container - either the one annotated as default, or if no container is annotated - the first one in the manifest.
The Python interpreter that is used while debugging is the one installed in the remote container, not the one in the run/debug config.
You can even omit its definition, but you'll get a warning message you'll have to skip every time you run/debug with Raftt.
To easily share your run/debug configuration with the rest of the team, mark the "store as project file" checkbox and commit the new file, typically located under .run
, to the repo.
To debug with Raftt, start by defining a "standard" debug configuration in your launch.json
file, as if you would debug the process locally. For help creating such a configuration, see VS Code docs.
Then, add the raftt
attribute to the debug config. This attribute has a single property, stating the workload
to debug.
In addition, the default working dir by VS Code is the workspace folder (usually the repo root). If this dir isn't mounted to the container, you must specify a different cwd
.
For example, here you can see the configuration for debugging the recommendations
service, as a part of our tutorial -
{
"name": "recommendations",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/src/recommendationservice/recommendation_server.py",
"cwd": "${workspaceFolder}/src/recommendationservice",
"raftt": {
"workload": "recommendations"
}
}
Debugging a sidecar container
To debug a sidecar container, add a property to the raftt
attribute - container
, whose value is the debugged container name. If not stated, the selected container is the workload's main container - either the one annotated as default, or if no container is annotated - the first one in the manifest.
Here you can see how to debug a container named sidecar
(that doesn't really exist in our sample project) -
{
"name": "recommendations",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/src/recommendationservice/recommendation_server.py",
"cwd": "${workspaceFolder}/src/recommendationservice",
"raftt": {
"workload": "recommendations",
"container": "sidecar"
}
}
To easily share your run/debug configuration with team members, make sure your launch.json
file is committed to the project repo.
Debugging
Once you completed the configuration, you can experience fully-featured interactive debugging directly in your cluster, including breakpoints, stepping, watching and modifying variables, etc..
The method for starting a run/debug session with Raftt differs between different IDEs -
- JetBrains IDEs
- VS Code
To start a run/debug session with Raftt, use the Run with Raftt
or Debug with Raftt
blue buttons, or select these options from the Run
menu.
Starting a run/debug session with a configuration that has the raftt
attribute will automatically start a Raftt debugging session. This can be triggered using the debugging pane in the side bar, keyboard shortcuts or the command palette.