Skip to content

Commit

Permalink
Added knob to break pipeline unless user opt-in (#4165)
Browse files Browse the repository at this point in the history
* Added knob to force agent fail if user doesn't opt-in updates on unsupported OS

* Resolved PR comments

---------

Co-authored-by: Kirill Ivlev <102740624+kirill-ivlev@users.noreply.github.com>
  • Loading branch information
ismayilov-ismayil and kirill-ivlev committed Mar 7, 2023
1 parent b4dd146 commit 1bc1fd1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/Agent.Sdk/Knob/AgentKnobs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
10 changes: 9 additions & 1 deletion src/Agent.Worker/JobRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,21 @@ public async Task<TaskResult> 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);

}
}

Expand Down
1 change: 1 addition & 0 deletions src/Misc/layoutbin/en-US/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down

0 comments on commit 1bc1fd1

Please sign in to comment.