Skip to content

Commit

Permalink
Update info about legacy http handler (#3775)
Browse files Browse the repository at this point in the history
Added the "deprecationInfo" property for deprecated knobs. Updated the warning message about using legacy http handler.
  • Loading branch information
Ivan Golubev authored Mar 9, 2022
1 parent 9042b0d commit 43189fc
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Agent.Sdk/Knob/AgentKnobs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public class AgentKnobs
public static readonly Knob UseLegacyHttpHandler = new DeprecatedKnob(
nameof(UseLegacyHttpHandler),
"Use the libcurl-based HTTP handler rather than .NET's native HTTP handler, as we did on .NET Core 2.1",
"Legacy http handler will be removed in one of the next agent releases with migration to .Net Core 6. We are highly recommend to not use it.",
new EnvironmentKnobSource(LegacyHttpVariableName),
new BuiltInDefaultKnobSource("false"));

Expand Down
7 changes: 7 additions & 0 deletions src/Agent.Sdk/Knob/Knob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,15 @@ namespace Agent.Sdk.Knob
public class DeprecatedKnob : Knob
{
public override bool IsDeprecated => true;
public string DeprecationInfo;
public DeprecatedKnob(string name, string description, params IKnobSource[] sources) : base(name, description, sources)
{
DeprecationInfo = "";
}

public DeprecatedKnob(string name, string description, string deprecationInfo, params IKnobSource[] sources) : base(name, description, sources)
{
DeprecationInfo = deprecationInfo;
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/Agent.Worker/JobExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,16 @@ public async Task<List<IStep>> InitializeJob(IExecutionContext jobContext, Pipel
HostContext.SecretMasker.AddValue(stringValue, $"JobExtension_InitializeJob_{knob.Name}");
}
var outputLine = $" Knob: {knob.Name} = {stringValue} Source: {value.Source.GetDisplayString()} {tag}";

if (knob.IsDeprecated)
{
context.Warning(outputLine);

string deprecationInfo = (knob as DeprecatedKnob).DeprecationInfo;
if (!string.IsNullOrEmpty(deprecationInfo))
{
context.Warning(deprecationInfo);
}
}
else
{
Expand Down

0 comments on commit 43189fc

Please sign in to comment.