Repository for reproducing an apparent breakpoint issue in VSCode Kubernetes remote attach debugging.
This code has been executed in WSL2 on a Windows 10 PC with Ubuntu 20.04. The functionality should be compaitble with any Linux distro that has Docker installed.
Running the VSCode task check-dependencies will attempt to install all necessary dependencies
- VSCode extensions
- ms-dotnettools.csharp
- ms-azuretools.vscode-dapr
- ms-azuretools.vscode-docker
- ms-kubernetes-tools.vscode-kubernetes-tools
- dapr
- minikube
- kubectl
- Build the code using the
buildtask. - Set breakpoints on:
- line 73 of
Program.cs - line 10 of
src/AbstractExample/AbstractExampleActor.cs - line 10 of
src/AbstractExample/AbstractExample.cs - line 26 of
src/Application/AggregateActor.cs
- line 73 of
The demonstration project includes an HTTP endpoint that accepts a boolean value (true or false) to drive operation
of the dapr actor in a test setup or through the dapr infrastructure itself. The dotnet run environment does not
include the dapr runtime, so only the true value will result in successful execution.
- Start the target environment
- Start VSCode debugger by launching or attaching to the actortest binary
- Open the web browser to the proper port with the
trueorfalserouter parameter binding indicated (e.g., http://localhost:5000/true)
The breakpoint will be successfully hit in two of the three methods for running this example.
Using the VSCode debugger, launch the .NET Core Launch (console) profile. Open http://localhost:5000/true and observe the breakpoints being hit. All breakpoints will successfully be matched to code files.
Using the VSCode debugger, launch the .NET with Dapr profile. Open http://localhost:5000/true and observe the breakpoints being hit. All breakpoints will successfully be matched to code files. Repeat with http://localhost:5000/false (to invoke the actor runtime) and observe the same success.
For kubernetes, we need to start the environment, perform a docker build, apply a YAML file, attach the debugger, and forward ports to localhost to demonstrate the issue.
- First start the minikube environment by running the
start-kube-environmenttask and wait for the cluster to start and dapr initialization to complete. - Now execute the
docker buildbuild task in VSCode. This build will target the minikube docker daemon for easy deployment. - Once the docker build completes, open the
deploy/actortest.ymlfile and run the Kubernetes: Apply command from the command palette. Since the YAML file contains all the resources necessary for the deployment, you'll get a popup warning about VSCode not being able to indicate what will change. Click Apply - we'll be fine. - Run the Kubernetes: Debug (Attach) command from the command palette and select the
actortest-<id>pod,actortestcontainer, and thedotnetenvironment. You should have an active debug session. - Finally, use the
forward-portscommand to launch a terminal process that fowards localhost port 5000 to port 80 on the actortest service. This allows the same access method as the other two environments.
Open http://localhost:5000/true to exercise the test path in the code. All breakpoints set will resolve to source code locations as before.
Now steer your browser to http://localhost:5000/false to exercise the actor runtime. Three of the four breakpoints hit
as before and resolve to source code mapping. The fourth breakpoint (at line 10 of
src/AbstractExample/AbstractExample.cs) breaks the execution but provides no mapping to source code in the IDE. Any
entry into the debug console results in an Evaluation failed indication. The call stack indicates a .NET ThreadPool
Worker is PAUSED ON BREAKPOINT, but the stack trace displays Error processing 'stackTrace' request. Unknown Error: 0x80131c35
Disconnect the debug session and run the cleanup-kube-environment task. This will remove dapr from the cluster and
stop minikube.