Adding debug for containers in IDEs#1106
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
TIP This summary will be updated as you push new changes. Give us feedback
bc14a1d to
a953b4a
Compare
anthonygego
left a comment
There was a problem hiding this comment.
Maybe we should enable this only on demand/when needed. Either passing an environment variable from PyCharm and frowarding it from the agent to the container, or rely on the existing debug flag.
If this fails silently if the server is not listening, this could be OK, but I guess in this case it would triy and time out. This is not a wanted behaviour as this would severly impact the execution time
A nice addition (not for this PR) would be to allow the user to specify the hostname and port of the debug server and keep those as default. If the docker stack is located on another host, the host-gateway IP won't match the debug server one. Besides, the hardcoded port may not be available on the developer host if it is already used by another service.
|
The existing debug_mode is defined for each job separately and is given by the BackendNewJob message to the docker agent. So it is best to use a new environment variable to indicate if debug through the IDE is wanted. Any suggestions for a good variable name so it isn't confused for a parameter for the remote ssh debug ? For a future PR for remote debugging : # Only for backend: local
local-config:
# debug_host: localhost # host that will be indicated to users when they want to use the task remote debug feature. Automatically guessed by
# default
debug_ports: 64000-64100 #port range use for remote debug feature |
Actually it might be more productive to directly add the options in the webapp config file and the docker agent CLI arguments.
If the docker agent is used on another host, the args are passed in the CLI. This In conclusion, |
|
A message is now added to stderr if the debug server is not available. It does not fail the job anymore. I have also fixed the time limit for a job to half an hour if the container debugging is enabled. Without it the job just stops after the set limit and debugging is not possible. Should I add that fixed limit as a config parameter ? |
| except Exception as e: | ||
| print("Failed to connect to pycharm debugger: {}".format(e)) | ||
| debug_server_unavailable = True |
There was a problem hiding this comment.
It seems it already prints a stack trace so maybe there already is a try/except behind this one which becomes unecessary. But not sure...
There was a problem hiding this comment.
There is indeed a stack trace :
Could not connect to host.docker.internal: 5678
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/_pydevd_bundle/pydevd_comm.py", line 443, in start_client
s.connect((host, port))
ConnectionRefusedError: [Errno 111] Connection refused
But I don't get wan't you want me to do. Should I remove the print ?
There was a problem hiding this comment.
There is no need for duplicate messages. Either catch the first exception if possible, or simply remove the second if it this not stop execution.
4304216 to
cb3f031
Compare
|
LGTM. |
This PR aims to add the possibility of interactive debug inside the containers running jobs.
Steps :
pydevd_pycharmpython package)Broader usage for all IDEs using the Debug Adapter Protocol (DAP)=> for future PRDo you think debug capabilities for the run files is an interesting addition ?