Skip to content

Commit a6efe61

Browse files
authored
Remove DebugPy (#10692)
* Remove DebugPy * Fix linter * Update setEnv.sh * Update dev compose with debug and python warnings * Remove kubernetes part of this as well
1 parent cffb416 commit a6efe61

File tree

7 files changed

+9
-171
lines changed

7 files changed

+9
-171
lines changed

docker-compose.override.debug.yml

Lines changed: 0 additions & 60 deletions
This file was deleted.

docker-compose.override.dev.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,30 @@ services:
55
volumes:
66
- '.:/app:z'
77
environment:
8-
PYTHONWARNINGS: always # We are strict during development so Warnings needs to be more verbose
8+
PYTHONWARNINGS: error # We are strict about Warnings during development
9+
DD_DEBUG: 'True'
910
DD_ADMIN_USER: "${DD_ADMIN_USER:-admin}"
1011
DD_ADMIN_PASSWORD: "${DD_ADMIN_PASSWORD:-admin}"
1112
DD_EMAIL_URL: "smtp://mailhog:1025"
1213
celeryworker:
1314
volumes:
1415
- '.:/app:z'
1516
environment:
16-
PYTHONWARNINGS: always # We are strict during development so Warnings needs to be more verbose
17+
PYTHONWARNINGS: error # We are strict about Warnings during development
18+
DD_DEBUG: 'True'
1719
DD_EMAIL_URL: "smtp://mailhog:1025"
1820
celerybeat:
1921
volumes:
2022
- '.:/app:z'
2123
environment:
22-
PYTHONWARNINGS: always # We are strict during development so Warnings needs to be more verbose
24+
PYTHONWARNINGS: error # We are strict about Warnings during development
25+
DD_DEBUG: 'True'
2326
initializer:
2427
volumes:
2528
- '.:/app:z'
2629
environment:
27-
PYTHONWARNINGS: always # We are strict during development so Warnings needs to be more verbose
30+
PYTHONWARNINGS: error # We are strict about Warnings during development
31+
DD_DEBUG: 'True'
2832
DD_ADMIN_USER: "${DD_ADMIN_USER:-admin}"
2933
DD_ADMIN_PASSWORD: "${DD_ADMIN_PASSWORD:-admin}"
3034
nginx:

docker/setEnv.sh

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
target_dir="${0%/*}/.."
66
override_link='docker-compose.override.yml'
77
override_file_dev='docker-compose.override.dev.yml'
8-
override_file_debug='docker-compose.override.debug.yml'
98
override_file_unit_tests='docker-compose.override.unit_tests.yml'
109
override_file_unit_tests_cicd='docker-compose.override.unit_tests_cicd.yml'
1110
override_file_integration_tests='docker-compose.override.integration_tests.yml'
@@ -77,19 +76,6 @@ function set_dev {
7776
fi
7877
}
7978

80-
function set_debug {
81-
get_current
82-
if [ "${current_env}" != debug ]
83-
then
84-
docker compose down
85-
rm -f ${override_link}
86-
ln -s ${override_file_debug} ${override_link}
87-
echo "Now using 'debug' configuration."
88-
else
89-
echo "Already using 'debug' configuration."
90-
fi
91-
}
92-
9379
function set_unit_tests {
9480
get_current
9581
if [ "${current_env}" != unit_tests ]

dojo/wsgi.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"""
1616
import logging
1717
import os
18-
import socket
1918

2019
from django.core.wsgi import get_wsgi_application
2120

@@ -27,37 +26,6 @@
2726
# os.environ["DJANGO_SETTINGS_MODULE"] = "dojo.settings"
2827
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dojo.settings.settings")
2928

30-
31-
# Shouldn't apply to docker-compose dev mode (1 process, 1 thread), but may be needed when enabling debugging in other contexts
32-
def is_debugger_listening(port):
33-
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
34-
return s.connect_ex(("127.0.0.1", port))
35-
36-
37-
debugpy_port = os.environ.get("DD_DEBUG_PORT") or 3000
38-
39-
# Checking for RUN_MAIN for those that want to run the app locally with the python interpreter instead of uwsgi
40-
if os.environ.get("DD_DEBUG") == "True" and not os.getenv("RUN_MAIN") and is_debugger_listening(debugpy_port) != 0:
41-
logger.info(f"DD_DEBUG is set to True, setting remote debugging on port {debugpy_port}")
42-
try:
43-
import debugpy # noqa: T100
44-
45-
# Required, otherwise debugpy will try to use the uwsgi binary as the python interpreter - https://github.com/microsoft/debugpy/issues/262
46-
debugpy.configure({
47-
"python": "python",
48-
"subProcess": True,
49-
})
50-
debugpy.listen(("0.0.0.0", debugpy_port)) # noqa: T100
51-
if os.environ.get("DD_DEBUG_WAIT_FOR_CLIENT") == "True":
52-
logger.info(f"Waiting for the debugging client to connect on port {debugpy_port}")
53-
debugpy.wait_for_client() # noqa: T100
54-
logger.debug("Debugging client connected, resuming execution")
55-
except RuntimeError as e:
56-
if str(e) != "Can't listen for client connections: [Errno 98] Address already in use":
57-
logger.exception(e)
58-
except Exception as e:
59-
logger.exception(e)
60-
6129
# This application object is used by any WSGI server configured to use this
6230
# file. This includes Django's development server, if the WSGI_APPLICATION
6331
# setting points here.

readme-docs/DOCKER.md

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -118,56 +118,7 @@ id -u
118118

119119
## Run with Docker Compose in development mode with debugpy (remote debug)
120120

121-
The debug mode, offers out of the box a debugging server listening on port 3000
122-
123-
```zsh
124-
# switch to debug configuration
125-
docker/setEnv.sh debug
126-
# then use docker-compose as usual
127-
./dc-up.sh
128-
```
129-
130-
This will run the application based on merged configurations from `docker-compose.yml` and `docker-compose.override.debug.yml`.
131-
132-
Alternatively (if using docker for windows for example), you can copy the override file over (and re-create the containers):
133-
```
134-
cp docker-compose.override.debug.yml docker-compose.override.yml
135-
./dc-down.sh
136-
./dc-up.sh
137-
```
138-
139-
The default configuration assumes port 3000 by default for debug.
140-
141-
But you can pass additional environment variables:
142-
- `DD_DEBUG_PORT` to define a different port
143-
- `DD_DEBUG_WAIT_FOR_CLIENT` - That's if you want to debugger to wait, right before calling `django.core.wsgi.get_wsgi_application()`
144-
145-
146-
### VS code
147-
Add the following python debug configuration (You would have to install the `ms-python.python`. Other setup may work.)
148-
149-
```
150-
{
151-
"name": "Remote DefectDojo",
152-
"type": "python",
153-
"request": "attach",
154-
"pathMappings": [
155-
{
156-
"localRoot": "${workspaceFolder}",
157-
"remoteRoot": "/app"
158-
}
159-
],
160-
"port": 3000,
161-
"host": "localhost"
162-
}
163-
```
164-
165-
You can now launch the remote debug from VS Code, place your breakpoints and step through the code.
166-
167-
> At present, 2 caveats:
168-
> - Static will not be present. You would have to `docker cp` them over from the nginx container
169-
> - For some reason, the page loading may hang. You can stop the loading and reload, the page will ultimately appear.
170-
121+
Some users have found value in using debugpy. A short guide to setting this up can be found [here](https://testdriven.io/blog/django-debugging-vs-code/)
171122

172123
## Access the application
173124
Navigate to <http://localhost:8080> where you can log in with username admin.

readme-docs/KUBERNETES.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,16 +176,6 @@ docker build --build-arg http_proxy=http://myproxy.com:8080 --build-arg https_pr
176176
docker build --build-arg http_proxy=http://myproxy.com:8080 --build-arg https_proxy=http://myproxy.com:8080 -t defectdojo/defectdojo-nginx -f Dockerfile.nginx .
177177
```
178178

179-
### Debug uWSGI with ptvsd
180-
181-
You can set breakpoints in code that is handled by uWSGI. The feature is meant to be used when you run locally on minikube, and mimics [what can be done with docker-compose](DOCKER.md#run-with-docker-compose-in-development-mode-with-ptvsd-remote-debug).
182-
183-
The port is currently hard-coded to 3000.
184-
185-
- In `values.yaml`, ensure the value for `enable_ptvsd` is set to `true` (the default is `false`). Make sure the change is taken into account in your deployment.
186-
- Have `DD_DEBUG` set to `True`.
187-
- Port forward port 3000 to the pod, such as `kubectl port-forward defectdojo-django-7886f49466-7cwm7 3000`.
188-
189179
### Upgrade the chart
190180

191181
If you want to change kubernetes configuration of use an updated docker image (evolution of defectDojo code), upgrade the application:

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ titlecase==2.4.1
4646
social-auth-app-django==5.4.2
4747
social-auth-core==4.5.4
4848
gitpython==3.1.43
49-
debugpy==1.8.5
5049
python-gitlab==4.9.0
5150
cpe==1.3.0
5251
packageurl-python==0.15.6

0 commit comments

Comments
 (0)