Skip to content

Add remote debugging feature for sonic-mgmt container#18009

Merged
yejianquan merged 1 commit intosonic-net:masterfrom
auspham:austinpham/debugpy
Apr 28, 2025
Merged

Add remote debugging feature for sonic-mgmt container#18009
yejianquan merged 1 commit intosonic-net:masterfrom
auspham:austinpham/debugpy

Conversation

@auspham
Copy link
Contributor

@auspham auspham commented Apr 16, 2025

Description of PR

Summary:
This PR adds remote debugging functionality using https://github.com/microsoft/debugpy support with vs-code for sonic-mgmt container. This will need the follow PR to be mereged as well:

In summary, one can setup a remote debug container when provide option --enable-debug. For example:

./setup-containers.sh sonic-mgmt-user_master --enable-debug

Which will automatically scan for available ports and establish a tunnel between docker and host for debugpy purpose. The user then can execute normal run_test command with --enable-debug added to the end to connect with their vscode client. For example:

./run_tests.sh -n vms-kvm-t0 -d vlab-01 -c bgp/test_bgp_fact.py -f vtestbed.yaml -i ../ansible/veos_vtb --enable-debug

Fixes # (issue) 32317137

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • New Test case
    • Skipped for non-supported platforms
  • Test case improvement

Back port request

  • 202012
  • 202205
  • 202305
  • 202311
  • 202405
  • 202411

Approach

What is the motivation for this PR?

To provide a native-like debug experience, improve our development efficiency.

How did you do it?

Described above

How did you verify/test it?

Verified on dev server

Any platform specific information?

Supported testbed topology if it's a new test case?

Documentation

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@auspham auspham force-pushed the austinpham/debugpy branch from e773640 to 87dad21 Compare April 16, 2025 07:46
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@auspham auspham force-pushed the austinpham/debugpy branch from 9e947a1 to 8c625a9 Compare April 17, 2025 13:02
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Signed-off-by: Austin Pham <[email protected]>
@auspham auspham force-pushed the austinpham/debugpy branch from 8c625a9 to fd6ee2c Compare April 24, 2025 08:07
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

wangxin pushed a commit to sonic-net/sonic-buildimage that referenced this pull request Apr 28, 2025
Why I did it
This enable debugpy https://github.com/microsoft/debugpy as part of the dependency to support native debugging via vscode.

The follow-up PR is sonic-net/sonic-mgmt#18009 to enable in sonic-mgmt container

Work item tracking
Microsoft ADO (number only): 32317137
How I did it
Add debugpy as part of pip library

How to verify it
Verified on dev-vm:

make -f Makefile.work BLDENV=bullseye SONIC_BUILD_JOBS=$(nproc) DEFAULT_CONTAINER_REGISTRY=publicmirror.azurecr.io ENABLE_DOCKER_BASE_PULL=y LEGACY_SONIC_MGMT_DOCKER=y target/docker-sonic-mgmt.gz
docker load -i target/docker-sonic-mgmt.gz
docker run -it --rm docker-sonic-mgmt:latest debugpy 

debugpy 1.8.14
See https://aka.ms/debugpy for documentation.

Usage: debugpy --listen | --connect
               [<host>:]<port>
               [--wait-for-client]
               [--configure-<name> <value>]...
               [--log-to <path>] [--log-to-stderr]
               <filename> | -m <module> | -c <code> | --pid <pid>
               [<arg>]...

Signed-off-by: Austin Pham <[email protected]>
Copy link
Collaborator

@yejianquan yejianquan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yejianquan yejianquan merged commit 2cccea3 into sonic-net:master Apr 28, 2025
18 checks passed
opcoder0 pushed a commit to opcoder0/sonic-mgmt that referenced this pull request Dec 8, 2025
Description of PR
Summary:
This PR adds remote debugging functionality using https://github.com/microsoft/debugpy support with vs-code for sonic-mgmt container. This will need the follow PR to be mereged as well:

feat: add debugpy dependency sonic-buildimage#22341
In summary, one can setup a remote debug container when provide option --enable-debug. For example:

./setup-containers.sh sonic-mgmt-user_master --enable-debug
Which will automatically scan for available ports and establish a tunnel between docker and host for debugpy purpose. The user then can execute normal run_test command with --enable-debug added to the end to connect with their vscode client. For example:

./run_tests.sh -n vms-kvm-t0 -d vlab-01 -c bgp/test_bgp_fact.py -f vtestbed.yaml -i ../ansible/veos_vtb --enable-debug
Fixes # (issue) 32317137

Approach
What is the motivation for this PR?
To provide a native-like debug experience, improve our development efficiency.

How did you do it?
Described above

How did you verify/test it?
Verified on dev server

Signed-off-by: Austin Pham <[email protected]>
AharonMalkin pushed a commit to AharonMalkin/sonic-mgmt that referenced this pull request Dec 16, 2025
Description of PR
Summary:
This PR adds remote debugging functionality using https://github.com/microsoft/debugpy support with vs-code for sonic-mgmt container. This will need the follow PR to be mereged as well:

feat: add debugpy dependency sonic-buildimage#22341
In summary, one can setup a remote debug container when provide option --enable-debug. For example:

./setup-containers.sh sonic-mgmt-user_master --enable-debug
Which will automatically scan for available ports and establish a tunnel between docker and host for debugpy purpose. The user then can execute normal run_test command with --enable-debug added to the end to connect with their vscode client. For example:

./run_tests.sh -n vms-kvm-t0 -d vlab-01 -c bgp/test_bgp_fact.py -f vtestbed.yaml -i ../ansible/veos_vtb --enable-debug
Fixes # (issue) 32317137

Approach
What is the motivation for this PR?
To provide a native-like debug experience, improve our development efficiency.

How did you do it?
Described above

How did you verify/test it?
Verified on dev server

Signed-off-by: Austin Pham <[email protected]>
Signed-off-by: Aharon Malkin <[email protected]>
gshemesh2 pushed a commit to gshemesh2/sonic-mgmt that referenced this pull request Dec 21, 2025
Description of PR
Summary:
This PR adds remote debugging functionality using https://github.com/microsoft/debugpy support with vs-code for sonic-mgmt container. This will need the follow PR to be mereged as well:

feat: add debugpy dependency sonic-buildimage#22341
In summary, one can setup a remote debug container when provide option --enable-debug. For example:

./setup-containers.sh sonic-mgmt-user_master --enable-debug
Which will automatically scan for available ports and establish a tunnel between docker and host for debugpy purpose. The user then can execute normal run_test command with --enable-debug added to the end to connect with their vscode client. For example:

./run_tests.sh -n vms-kvm-t0 -d vlab-01 -c bgp/test_bgp_fact.py -f vtestbed.yaml -i ../ansible/veos_vtb --enable-debug
Fixes # (issue) 32317137

Approach
What is the motivation for this PR?
To provide a native-like debug experience, improve our development efficiency.

How did you do it?
Described above

How did you verify/test it?
Verified on dev server

Signed-off-by: Austin Pham <[email protected]>
Signed-off-by: Guy Shemesh <[email protected]>
gshemesh2 pushed a commit to gshemesh2/sonic-mgmt that referenced this pull request Jan 26, 2026
Description of PR
Summary:
This PR adds remote debugging functionality using https://github.com/microsoft/debugpy support with vs-code for sonic-mgmt container. This will need the follow PR to be mereged as well:

feat: add debugpy dependency sonic-buildimage#22341
In summary, one can setup a remote debug container when provide option --enable-debug. For example:

./setup-containers.sh sonic-mgmt-user_master --enable-debug
Which will automatically scan for available ports and establish a tunnel between docker and host for debugpy purpose. The user then can execute normal run_test command with --enable-debug added to the end to connect with their vscode client. For example:

./run_tests.sh -n vms-kvm-t0 -d vlab-01 -c bgp/test_bgp_fact.py -f vtestbed.yaml -i ../ansible/veos_vtb --enable-debug
Fixes # (issue) 32317137

Approach
What is the motivation for this PR?
To provide a native-like debug experience, improve our development efficiency.

How did you do it?
Described above

How did you verify/test it?
Verified on dev server

Signed-off-by: Austin Pham <[email protected]>
Signed-off-by: Guy Shemesh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants