Skip to content

Commit

Permalink
add instrumentation for intermittent DNS failures (dotnet/corefx#34934)
Browse files Browse the repository at this point in the history
* add instrumentation for dotnet/corefx#32797

* actually retry the lookup

* use PlatformID.Unix


Commit migrated from dotnet/corefx@673fe78
  • Loading branch information
wfurt committed Jan 30, 2019
1 parent 6da846c commit a0d2073
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ public void TryGetAddrInfo_LocalHost()
Assert.NotNull(hostEntry.Aliases);
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArm64Process))] // [ActiveIssue(32797)]
public void TryGetAddrInfo_HostName()
{
string hostName = NameResolutionPal.GetHostName();
Expand All @@ -50,6 +49,16 @@ public void TryGetAddrInfo_HostName()
// machine configurations, which varies by distro and is often inconsistent.
return;
}

// Temporary instrumentation for #32797
if (error == SocketError.TryAgain && Environment.OSVersion.Platform == PlatformID.Unix)
{
error = NameResolutionPal.TryGetAddrInfo(hostName, out hostEntry, out nativeErrorCode);
if (error != SocketError.TryAgain)
{
throw new InvalidOperationException("Name resolution failure preventable with retry");
}
}

Assert.Equal(SocketError.Success, error);
Assert.NotNull(hostEntry);
Expand Down Expand Up @@ -92,7 +101,6 @@ public void TryGetAddrInfo_LocalHost_TryGetNameInfo()
Assert.NotNull(name);
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotArm64Process))] // [ActiveIssue(32797)]
public void TryGetAddrInfo_HostName_TryGetNameInfo()
{
string hostName = NameResolutionPal.GetHostName();
Expand All @@ -109,6 +117,16 @@ public void TryGetAddrInfo_HostName_TryGetNameInfo()
return;
}

// Temporary instrumentation for #32797
if (error == SocketError.TryAgain && Environment.OSVersion.Platform == PlatformID.Unix)
{
error = NameResolutionPal.TryGetAddrInfo(hostName, out hostEntry, out nativeErrorCode);
if (error != SocketError.TryAgain)
{
throw new InvalidOperationException("Name resolution failure preventable with retry");
}
}

Assert.Equal(SocketError.Success, error);
Assert.NotNull(hostEntry);

Expand Down

0 comments on commit a0d2073

Please sign in to comment.