Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix telemetry for Socket connects to Dns endpoints #54071

Merged
merged 1 commit into from
Jun 24, 2021

Conversation

MihaZupan
Copy link
Member

@MihaZupan MihaZupan commented Jun 11, 2021

Fixes #43931
Fixes #46030

When connecting to a DnsEndPoint, DNS may give us multiple addresses that we try to connect to.

For example let's say foo.test resolves to [ 52.201.75.112, 52.201.75.113, 52.201.75.114 ] where the first two addresses refuse connections.

Today, you would see (6.0 main):

ConnectStart:  InterNetworkV6:28:{1,187,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,52,201,75,112,0,0,0,0}
ConnectStart:  InterNetworkV6:28:{1,187,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,52,201,75,113,0,0,0,0}
ConnectStart:  InterNetworkV6:28:{1,187,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,52,201,75,114,0,0,0,0}
ConnectStop

What you actually want to see is (5.0 / this PR behave this way):

ConnectStart:  InterNetworkV6:28:{1,187,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,52,201,75,112,0,0,0,0}
ConnectFailed: TimedOut
ConnectStop

ConnectStart:  InterNetworkV6:28:{1,187,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,52,201,75,113,0,0,0,0}
ConnectFailed: TimedOut
ConnectStop

ConnectStart:  InterNetworkV6:28:{1,187,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,52,201,75,114,0,0,0,0}
ConnectStop

The issue was that DnsConnectAsync was logging a Stop event while disabling Failed/Stop for inner connect attempts.
As long as the DnsConnectAsync wrapper does not emit events itself, it's fine to leave inner connects as-is to get correct behaviour.

You can see the above behaviour by adding the following to the hosts file

52.201.75.112 foo.test
52.201.75.113 foo.test
52.201.75.114 foo.test

And running this SocketConnectTest.cs

@MihaZupan MihaZupan added this to the 6.0.0 milestone Jun 11, 2021
@MihaZupan MihaZupan requested review from stephentoub and a team June 11, 2021 18:05
@ghost
Copy link

ghost commented Jun 11, 2021

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #43931
Fixes #46030

When connecting to a DnsEndPoint, DNS may give us multiple addresses that we try to connect to.

For example let's say foo.test resolves to [ 52.201.75.112, 52.201.75.113, 52.201.75.114 ] where the first two addresses refuse connections.

Today, you would see (6.0 main):

ConnectStart:  InterNetworkV6:28:{1,187,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,52,201,75,112,0,0,0,0}
ConnectStart:  InterNetworkV6:28:{1,187,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,52,201,75,113,0,0,0,0}
ConnectStart:  InterNetworkV6:28:{1,187,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,52,201,75,114,0,0,0,0}
ConnectStop

What you actually want to see is (5.0 / this PR behave this way):

ConnectStart:  InterNetworkV6:28:{1,187,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,52,201,75,112,0,0,0,0}
ConnectFailed: TimedOut
ConnectStop

ConnectStart:  InterNetworkV6:28:{1,187,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,52,201,75,113,0,0,0,0}
ConnectFailed: TimedOut
ConnectStop

ConnectStart:  InterNetworkV6:28:{1,187,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,52,201,75,114,0,0,0,0}
ConnectStop
Author: MihaZupan
Assignees: -
Labels:

area-System.Net.Sockets

Milestone: 6.0.0

@@ -113,7 +113,7 @@ public void AcceptStart(EndPoint address)
{
if (IsEnabled(EventLevel.Informational, EventKeywords.All))
{
AcceptStart(address.ToString());
AcceptStart(address.Serialize().ToString());
Copy link
Member Author

@MihaZupan MihaZupan Jun 11, 2021

Choose a reason for hiding this comment

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

This makes it so that both Sync and Async AcceptStart events use the same format for the address.

(changes AcceptAsync to behave the same way as Accept/Connect/ConnectAsync)

@MihaZupan
Copy link
Member Author

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

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

If this does the right thing, great.

@MihaZupan MihaZupan merged commit f3af8d8 into dotnet:main Jun 24, 2021
thaystg added a commit to thaystg/runtime that referenced this pull request Jun 24, 2021
…bugger2

* origin/main: (107 commits)
  Disable MacCatalyst arm64 PR test runs on staging pipeline (dotnet#54678)
  [WASM] Fix async/await in config loading (dotnet#54652)
  Fix for heap_use_after_free flagged by sanitizer (dotnet#54679)
  [wasm] Bump emscripten to 2.0.23 (dotnet#53603)
  Fix compiler references when building inside VS (dotnet#54614)
  process more TLS frames at one when available (dotnet#50815)
  Add PeriodicTimer (dotnet#53899)
  UdpClient with span support (dotnet#53429)
  exclude fragile tests (dotnet#54671)
  get last error before calling a method that might fail as well (dotnet#54667)
  [FileStream] add tests for device and UNC paths (dotnet#54545)
  Fix sporadic double fd close (dotnet#54660)
  Remove Version.Clone from AssemblyName.Clone (dotnet#54621)
  [wasm] Enable fixed libraries tests (dotnet#54641)
  [wasm] Fix blazor/aot builds (dotnet#54651)
  [mono][wasm] Fix compilation error on wasm (dotnet#54659)
  Fix telemetry for Socket connects to Dns endpoints (dotnet#54071)
  [wasm] Build static components; include hot_reload in runtime (dotnet#54568)
  [wasm][debugger] Reuse debugger-agent on wasm debugger (dotnet#52300)
  Put Crossgen2 in sync with dotnet#54235 (dotnet#54438)
  ...
@ghost ghost locked as resolved and limited conversation to collaborators Jul 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.