diff --git a/src/Agent.Sdk/Knob/AgentKnobs.cs b/src/Agent.Sdk/Knob/AgentKnobs.cs index c768e5870a..7ef9e2864f 100644 --- a/src/Agent.Sdk/Knob/AgentKnobs.cs +++ b/src/Agent.Sdk/Knob/AgentKnobs.cs @@ -282,6 +282,13 @@ public class AgentKnobs "Disable agent downgrades. Upgrades will still be allowed.", new EnvironmentKnobSource("AZP_AGENT_DOWNGRADE_DISABLED"), new BuiltInDefaultKnobSource("false")); + + public static readonly Knob AcknowledgeNoUpdates = new Knob( + nameof(AcknowledgeNoUpdates), + "Opt-in to continue using agent without updates on unsopperted OS", + new EnvironmentKnobSource("AGENT_ACKNOWLEDGE_NO_UPDATES"), + new RuntimeKnobSource("AGENT_ACKNOWLEDGE_NO_UPDATES"), + new BuiltInDefaultKnobSource("false")); public static readonly Knob PermissionsCheckFailsafe = new Knob( nameof(PermissionsCheckFailsafe), diff --git a/src/Agent.Worker/JobRunner.cs b/src/Agent.Worker/JobRunner.cs index 96f073e6a6..f24da232d5 100644 --- a/src/Agent.Worker/JobRunner.cs +++ b/src/Agent.Worker/JobRunner.cs @@ -128,13 +128,21 @@ public async Task RunAsync(Pipelines.AgentJobRequestMessage message, } if (!string.IsNullOrWhiteSpace(notSupportNet6Message)) - { + { + if(!AgentKnobs.AcknowledgeNoUpdates.GetValue(jobContext).AsBoolean()) + { + jobContext.Error(StringUtil.Loc("FailAgentOnUnsupportedOs")); + return await CompleteJobAsync(jobServer, jobContext, message, TaskResult.Failed); + } + jobContext.AddIssue(new Issue() { Type = IssueType.Warning, Message = notSupportNet6Message }); } } catch (Exception ex) { Trace.Error($"Error has occurred while checking if system supports .NET 6: {ex}"); + return await CompleteJobAsync(jobServer, jobContext, message, TaskResult.Failed); + } } diff --git a/src/Misc/layoutbin/en-US/strings.json b/src/Misc/layoutbin/en-US/strings.json index 1653a92e8a..d82b3e363a 100644 --- a/src/Misc/layoutbin/en-US/strings.json +++ b/src/Misc/layoutbin/en-US/strings.json @@ -299,6 +299,7 @@ "ExpectedMappingLocalPath": "Expected mapping[{0}] local path: '{1}'. Actual: '{2}'", "ExpectedMappingRecursive": "Expected mapping[{0}] recursive: '{1}'. Actual: '{2}'", "ExpectedMappingServerPath": "Expected mapping[{0}] server path: '{1}'. Actual: '{2}'", + "FailAgentOnUnsupportedOs": "This operating system will stop receiving updates of the Pipelines Agent in the future. To be able to continue to run pipelines please upgrade the operating system or set an environment variable or agent knob \"AGENT_ACKNOWLEDGE_NO_UPDATES\" to \"true\". See https://aka.ms/azdo-pipeline-agent-nosupport for more information.", "Failed": "Failed: ", "FailedDeletingTempDirectory0Message1": "Failed to delete temporary directory '{0}'. {1}", "FailedTestsInResults": "There are one or more test failures detected in result files. Detailed summary of published test results can be viewed in the Tests tab.",