microsoft / mindaro

Bridge to Kubernetes - for Visual Studio and Visual Studio Code
MIT License
307 stars 106 forks source link

File path changed when debugging in Bridge to Kubernetes #216

Closed Vaccano closed 3 years ago

Vaccano commented 3 years ago

Describe the bug I am making an operation that reads from the file \sys\fs\cgroup\memory\memory.usage_in_bytes. (I do this to calculate metrics for health checks.)

When I run this via docker compose on my local machine, it works correctly. (Finds the file and reads it.) It also works correctly when I run it in my Kubernetes cluster.

But when I run it in a debug session using Bridge to Kuberentes, I get the following exception:

"Could not find a part of the path 'C:\\sys\\fs\\cgroup\\memory\\memory.usage_in_bytes'."

The fact that it is adding a C: to the front is fishy to me. Almost as if it thinks it is running on Windows? (Not sure how that would be possible.)

To Reproduce

  1. Create an ASP.Net Core 3.1 Web API application.

  2. In an operation in your controller, add the following code:

    string memoryUsageFile = "/sys/fs/cgroup/memory/memory.usage_in_bytes"; var memoryUsage = System.IO.File.ReadAllText(memoryUsageFile); Console.Writeline(memoryUsage);

  3. Set a break point on the first line.

  4. Debug with Bridge to Kubernetes

  5. Step over the second line.

  6. The exception is thrown.

**Expected behavior** The file path would not change to have a `C:` in front of it. And that the file contents would be retrieved successfully. **Logs** I can provide logs privately if needed. **Environment Details** Client used (VS Code/Visual Studio): Visual Studio 16.9.2 Client's version: ? (Not sure what client you are referring to.) Operating System: Windows 10 **Additional context** None that I can think of.
pragyamehta commented 3 years ago

@Vaccano Thanks for reaching out to us! When you debug with Bridge to Kubernetes, the code you are debugging actually runs locally on your machine. We "bridge" all calls to and from the code running locally to the other microservices running in your cluster. I see you are running this on a Windows 10 machine, which is why it tries to look for the file path locally in the C drive on your machine and does not find it. You can use this link to download existing volumes from your running container to your local machine which should get you past this error. Let me know if you have any questions.