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

Add knob to enable fetching net6.json file from GitHub #4200

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Agent.Sdk/Knob/AgentKnobs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -431,5 +431,11 @@ public class AgentKnobs
new RuntimeKnobSource("AGENT_DISABLE_DRAIN_QUEUES_AFTER_TASK"),
new EnvironmentKnobSource("AGENT_DISABLE_DRAIN_QUEUES_AFTER_TASK"),
new BuiltInDefaultKnobSource("false"));

public static readonly Knob EnableFetchingNet6List = new Knob(
nameof(EnableFetchingNet6List),
"Forces the agent to fetch list of .NET 6 supporting systems from server",
new EnvironmentKnobSource("AGENT_ENABLE_FETCHING_NET6_LIST"),
new BuiltInDefaultKnobSource("false"));
}
}
9 changes: 8 additions & 1 deletion src/Agent.Sdk/Util/PlatformUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,10 @@ private async static Task<OperatingSystem[]> GetNet6SupportedSystems()
string serverFileUrl = "https://raw.githubusercontent.com/microsoft/azure-pipelines-agent/master/src/Agent.Listener/net6.json";
string supportOSfilePath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "net6.json");
string supportOSfileContent;
bool supportOSfileExists = File.Exists(supportOSfilePath);

if (!File.Exists(supportOSfilePath) || File.GetLastWriteTimeUtc(supportOSfilePath) < DateTime.UtcNow.AddHours(-1))
if ((!supportOSfileExists || File.GetLastWriteTimeUtc(supportOSfilePath) < DateTime.UtcNow.AddHours(-1))
&& AgentKnobs.EnableFetchingNet6List.GetValue(_knobContext).AsBoolean())
{
HttpResponseMessage response = await httpClient.GetAsync(serverFileUrl);
if (!response.IsSuccessStatusCode)
Expand All @@ -335,6 +337,11 @@ private async static Task<OperatingSystem[]> GetNet6SupportedSystems()
return net6SupportedSystems;
}

if (!supportOSfileExists)
{
throw new FileNotFoundException("File with list of systems supporting .NET 6 is absent", supportOSfilePath);
}

supportOSfileContent = await File.ReadAllTextAsync(supportOSfilePath);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Agent.Worker/JobRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ public async Task<TaskResult> RunAsync(Pipelines.AgentJobRequestMessage message,
}
catch (Exception ex)
{
jobContext.Warning($"Error has occurred while checking if system supports .NET 6: {ex.Message}");
Trace.Error($"Error has occurred while checking if system supports .NET 6: {ex}");
KonstantinTyukalov marked this conversation as resolved.
Show resolved Hide resolved
return await CompleteJobAsync(jobServer, jobContext, message, TaskResult.Failed);

}
}
Expand Down