Repository navigation
Build dotnet-monitor tool as ASP.NET Core 3.1 application. - #1420
Conversation
Use Brotli compression instead of GZip.
josalem
left a comment
There was a problem hiding this comment.
I think this looks good to me 😃. The only scenario that might be worth testing would be configuring dotnet monitor with a diagnostic port that it creates itself. If there were dragons lurking that's where I imagine they'd be, but I can't think of anything immediately problematic. The runtime is capable of connecting to itself via the default listen port, so I would wager that the same should be true of a connect port.
@josalem, one thing that I do notice, which blocks this test from working, is that if a runtime instance starts up in connect mode and the port that it is trying to connect to doesn't exist (e.g. dotnet-monitor is not running yet), the runtime instance will forever ignore anything that establishes that port in the future. So if it pauses on start, then the runtime just hangs forever. If it doesn't pause on start, then it continues on running and ignores the port. Without disabling the pause on start, having the dotnet-monitor server listen to itself will block forever (the server never comes up because managed code execution is blocked until the server sends the ResumeRuntime command... chicken-and-egg). With disabling pause on start, the dotnet-monitor server doesn't see itself because the runtime gives up on connecting to the port. |
How do you mean? If the port is configured to suspend it would make sense that it would hang (chicken-egg problem you mentioned), but if it isn’t configured to suspend, the runtime should continually try to connect to the port with an exponential falloff. The logic isn’t supposed to give up on connecting to the port, it will just retry after a timeout if it can’t connect. If I recall the max timeout is 250ms. Are you seeing it never connect to itself? |
@josalem, sorry, I miscalled what the actual problem was. The "have dotnet-monitor connect to itself" test should work if I try it again. The problem that I was recalling is that if a runtime instance is configured to connect to a diagnostic port, a diagnostic tool then hosts its listening port at that location (which works fine), then the diagnostic tool shuts down, and finally a diagnostic tool hosts its listening port at the same location, then the runtime instance will not connect to the second instance of the tool or any subsequent tools that host their listening port at that location. |
@jander-msft, that's troubling. I have tests in the runtime repo that specifically check for the scenario of a tool closing its port and creating it again. While the test is pathological and does this in a tight loop, I would expect a more normal scenario like you described to work cleanly. Specifically, this snippet here: https://github.com/dotnet/runtime/blob/1e6e8d9c8faa9a0dd51c2de67fcf1f5e0a4a1ed5/src/tests/tracing/eventpipe/reverseouter/reverseouter.cs#L71-L75
For reference, this is how the server is cleaned up in those tests: |
I'm observing this behavior on my local Windows machine, which is using named pipes, so there are no remnant files that should be interfering with this. |
Add support for GetProcessInfo command.
Refactor to computer filters only once for lifetime of DiagnosticServices instance.
Those tests run and pass on Windows too, so I'd be equally troubled if that were happening there as well. |
What I've found is that if I have dotnet-monitor call stream.Disconnect before disposing it, the the runtime instance will reconnect when the server comes back up later. That tells me that the runtime instance is expecting the diagnostic pipe/socket to be explicitly disconnected/closed before it tries to reconnect again. I think this would need to be fixed in the runtime because either something is going to forget to gracefully disconnect the stream (e.g. dotnet-monitor), something malicious could just not do it, or the diagnostic tool process could crash and not have a chance to send that disconnect. |
I'll look at this. I would expect the kernel to clean up any open NamedPipe handles if a server process were to crash/close without gracefully shutting down a pipe. Based on the docs, I would expect a call to |
Change port description service into options configuration.
noahfalk
left a comment
There was a problem hiding this comment.
LGTM (with the caveat I haven't been paying too close attention to the higher in the stack components)
This change has dotnet-monitor built for ASP.NET Core 3.1.
One major benefit is that when it is published as a tool it doesn't have to package the various Microsoft.AspNetCore.* and Microsoft.Extensions.* assemblies from .NET 2.1, which minimizes the size of the tool (as netcoreapp2.1, it's size was 22.3 MB; as netcoreapp3.1, it's size is 7.3 MB).
Filtering of the dotnet-monitor process has been implemented in a new IEndpointInfoSource implementation that is specific to the dotnet-monitor tool project; class is named FilteredEndpointInfoSource. It also selects the IEndpointInfoSource implementation based on options configuration provided by dependency injection. An additional benefit this refactor provides is that the ServerEndpoingInfoSource is now properly disposed by the service container whereas before it was not disposed because it was created outside of the service container.
closes #1270