From 0efdd117b998db5e28cd273699e6c2d8e58e8242 Mon Sep 17 00:00:00 2001 From: Bruno Rocha Date: Fri, 29 Nov 2024 15:27:52 +0000 Subject: [PATCH] Enable tty by default --- dev/compose/README.md | 32 +++++++++----------------------- dev/compose/aap.yaml | 24 +++++++++--------------- dev/compose/community.yaml | 25 ++++++++++--------------- dev/compose/insights.yaml | 26 ++++++++++---------------- 4 files changed, 38 insertions(+), 69 deletions(-) diff --git a/dev/compose/README.md b/dev/compose/README.md index 8efbcbc5a..2adffda3b 100644 --- a/dev/compose/README.md +++ b/dev/compose/README.md @@ -220,25 +220,7 @@ Run with legacy oci-env, check the [Running oci-env integration tests](../../doc ### Debugging -#### Step 1 - Enable tty and stdin on the container you want to debug - -For example, if you are debugging the `migrations` container, edit the migrations: service -on `aap.yaml` and find the lines. - -```yaml -# uncomment below when debugging -# stdin_open: true -# tty: true -``` - -and remove the comment - -```yaml -stdin_open: true -tty: true -``` - -#### Step 2 - Add the breakpoint +#### Step 1 - Add the breakpoint Edit the file you want to debug and add a breakpoint @@ -249,9 +231,9 @@ __import__("ipdb").set_trace() > [!TIP] > Replace if you are using a different debugger, however the images has only **pdb** and **ipdb** installed. -If you discover other ways of debugging, likle connecting dab protocol or vscode debugger, please update this file! +If you discover other ways of debugging, like connecting dap protocol or vscode debugger, please update this file! -#### Step 3- Now execute your stack or just the container you are trying to debug. +#### Step 2 - Now execute your stack or just the container you are trying to debug. Example: @@ -261,13 +243,17 @@ $ docker compose -f dev/compose/aap.yaml up migrations # The container will keep running stopped on the breakpoint. ``` -#### Step 4- Attach +#### Step 3 - Attach ```bash -$ docker compose -f dev/compose/insights.yaml attach migrations +$ docker compose -f dev/compose/aap.yaml attach migrations ipdb> ``` +> [!IMPORTANT] +> To detach from the container DO NOT use Ctrl+c, +> instead, use Ctrl-p Ctrl-q + --- **TBD** diff --git a/dev/compose/aap.yaml b/dev/compose/aap.yaml index 41538aeb0..f09282a83 100644 --- a/dev/compose/aap.yaml +++ b/dev/compose/aap.yaml @@ -79,6 +79,10 @@ x-common-env: &common-env # $ DEV_SOURCE_PATH="pulp_container:galaxy_ng" docker compose -f dev/compose/aap.yaml up DEV_SOURCE_PATH: +# allow attaching to the running container +x-debugging: &debugging + stdin_open: true + tty: true services: base_img: @@ -127,6 +131,7 @@ services: environment: <<: *common-env user: root + <<: *debugging command: | bash -c " set -e; @@ -140,9 +145,6 @@ services: touch /var/lib/pulp/.migrated; " - # uncomment below when debugging - # stdin_open: true - # tty: true api: image: "localhost/galaxy_ng/galaxy_ng:dev" @@ -163,6 +165,7 @@ services: - default - service-mesh user: root + <<: *debugging command: | bash -c " /src/galaxy_ng/dev/compose/bin/devinstall; @@ -170,9 +173,6 @@ services: /src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-api " - # uncomment below when debugging - # stdin_open: true - # tty: true content: image: "localhost/galaxy_ng/galaxy_ng:dev" @@ -193,6 +193,7 @@ services: - default - service-mesh user: root + <<: *debugging command: | bash -c " /src/galaxy_ng/dev/compose/bin/devinstall; @@ -200,9 +201,6 @@ services: /src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-content " - # uncomment below when debugging - # stdin_open: true - # tty: true worker: image: "localhost/galaxy_ng/galaxy_ng:dev" @@ -218,6 +216,7 @@ services: environment: <<: *common-env user: root + <<: *debugging command: | bash -c " /src/galaxy_ng/dev/compose/bin/devinstall; @@ -228,9 +227,6 @@ services: /src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-worker " - # uncomment below when debugging - # stdin_open: true - # tty: true manager: image: "localhost/galaxy_ng/galaxy_ng:dev" @@ -247,6 +243,7 @@ services: environment: <<: *common-env user: root + <<: *debugging command: | bash -c " /src/galaxy_ng/dev/compose/bin/devinstall; @@ -287,9 +284,6 @@ services: # Keep it running indefinitely to enable `docker compose -f ... exec manager /bin/bash`; tail -f /dev/null " - # uncomment below when debugging - # stdin_open: true - # tty: true nginx: image: "nginx:latest" diff --git a/dev/compose/community.yaml b/dev/compose/community.yaml index 8b3e01f3c..505f3b01e 100644 --- a/dev/compose/community.yaml +++ b/dev/compose/community.yaml @@ -89,6 +89,11 @@ x-common-env: &common-env DEV_SOURCE_PATH: +# allow attaching to the running container +x-debugging: &debugging + stdin_open: true + tty: true + services: base_img: build: @@ -148,6 +153,7 @@ services: environment: <<: *common-env user: root + <<: *debugging command: | bash -c " set -e; @@ -161,9 +167,6 @@ services: touch /var/lib/pulp/.migrated; " - # uncomment below when debugging - # stdin_open: true - # tty: true api: image: "localhost/galaxy_ng/galaxy_ng:dev" @@ -184,15 +187,13 @@ services: - default - service-mesh user: root + <<: *debugging command: | bash -c " /src/galaxy_ng/dev/compose/bin/devinstall; /src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated; /src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-api " - # uncomment below when debugging - # stdin_open: true - # tty: true content: image: "localhost/galaxy_ng/galaxy_ng:dev" @@ -213,15 +214,13 @@ services: - default - service-mesh user: root + <<: *debugging command: | bash -c " /src/galaxy_ng/dev/compose/bin/devinstall; /src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated; /src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-content " - # uncomment below when debugging - # stdin_open: true - # tty: true worker: image: "localhost/galaxy_ng/galaxy_ng:dev" @@ -237,15 +236,13 @@ services: environment: <<: *common-env user: root + <<: *debugging command: | bash -c " /src/galaxy_ng/dev/compose/bin/devinstall; /src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated; /src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-worker " - # uncomment below when debugging - # stdin_open: true - # tty: true manager: image: "localhost/galaxy_ng/galaxy_ng:dev" @@ -262,6 +259,7 @@ services: environment: <<: *common-env user: root + <<: *debugging command: | bash -c " /src/galaxy_ng/dev/compose/bin/devinstall; @@ -288,9 +286,6 @@ services: # Keep it running indefinitely to enable `docker compose -f ... exec manager /bin/bash`; tail -f /dev/null " - # uncomment below when debugging - # stdin_open: true - # tty: true nginx: image: "nginx:latest" diff --git a/dev/compose/insights.yaml b/dev/compose/insights.yaml index 8f45fbde3..9963ccd19 100644 --- a/dev/compose/insights.yaml +++ b/dev/compose/insights.yaml @@ -68,7 +68,11 @@ x-common-env: &common-env # $ DEV_SOURCE_PATH="pulp_container:galaxy_ng" docker compose -f dev/compose/aap.yaml up DEV_SOURCE_PATH: - +# allow attaching to the running container +x-debugging: &debugging + stdin_open: true + tty: true + services: base_img: build: @@ -127,6 +131,7 @@ services: environment: <<: *common-env user: root + <<: *debugging command: | bash -c " set -e; @@ -140,9 +145,6 @@ services: touch /var/lib/pulp/.migrated; " - # uncomment below when debugging - # stdin_open: true - # tty: true api: image: "localhost/galaxy_ng/galaxy_ng:dev" @@ -163,15 +165,13 @@ services: - default - service-mesh user: root + <<: *debugging command: | bash -c " /src/galaxy_ng/dev/compose/bin/devinstall; /src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated; /src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-api " - # uncomment below when debugging - # stdin_open: true - # tty: true content: image: "localhost/galaxy_ng/galaxy_ng:dev" @@ -192,15 +192,13 @@ services: - default - service-mesh user: root + <<: *debugging command: | bash -c " /src/galaxy_ng/dev/compose/bin/devinstall; /src/galaxy_ng/dev/compose/bin/wait /var/lib/pulp/.migrated; /src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-content " - # uncomment below when debugging - # stdin_open: true - # tty: true worker: image: "localhost/galaxy_ng/galaxy_ng:dev" @@ -216,6 +214,7 @@ services: environment: <<: *common-env user: root + <<: *debugging command: | bash -c " /src/galaxy_ng/dev/compose/bin/devinstall; @@ -226,9 +225,6 @@ services: /src/galaxy_ng/dev/compose/bin/reloader /venv/bin/pulpcore-worker " - # uncomment below when debugging - # stdin_open: true - # tty: true manager: image: "localhost/galaxy_ng/galaxy_ng:dev" @@ -245,6 +241,7 @@ services: environment: <<: *common-env user: root + <<: *debugging command: | bash -c " /src/galaxy_ng/dev/compose/bin/devinstall; @@ -275,9 +272,6 @@ services: # Keep it running indefinitely to enable `docker compose -f ... exec manager /bin/bash`; tail -f /dev/null " - # uncomment below when debugging - # stdin_open: true - # tty: true nginx: image: "nginx:latest"