Skip to content

Commit

Permalink
implementd AsBooleanStrict and check in JobRunner
Browse files Browse the repository at this point in the history
  • Loading branch information
sergey-koryshev committed Mar 3, 2023
1 parent 1a311da commit a1c0c67
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/Agent.Worker/JobRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,25 @@ public async Task<TaskResult> RunAsync(Pipelines.AgentJobRequestMessage message,
return await CompleteJobAsync(jobServer, jobContext, message, TaskResult.Failed);
}

// check if knob DrainQueuesAfterTask has correct value
bool defaultDrainQueuesAfterTask = AgentKnobs.DrainQueuesAfterTask.GetValue<BuiltInDefaultKnobSource>(jobContext).AsBoolean();
try
{
AgentKnobs.DrainQueuesAfterTask.GetValue(jobContext).AsBooleanStrict();
}
catch (Exception ex)
{
switch (ex)
{
case ArgumentException _:
case FormatException _:
jobContext.Warning($"Knob 'AGENT_DRAIN_QUEUES_AFTER_TASK' has wrong value, default value '{defaultDrainQueuesAfterTask}' will be set");
break;
default:
throw;
}
}

// trace out all steps
Trace.Info($"Total job steps: {jobSteps.Count}.");
Trace.Verbose($"Job steps: '{string.Join(", ", jobSteps.Select(x => x.DisplayName))}'");
Expand Down
9 changes: 8 additions & 1 deletion src/Agent.Worker/StepsRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,14 @@ private async Task RunStepAsync(IStep step, CancellationToken jobCancellationTok
step.ExecutionContext.Section(StringUtil.Loc("StepFinishing", step.DisplayName));
step.ExecutionContext.Complete();

if (AgentKnobs.DrainQueuesAfterTask.GetValue(step.ExecutionContext).AsBoolean() == true)
bool drainQueuesAfterTask = AgentKnobs.DrainQueuesAfterTask.GetValue<BuiltInDefaultKnobSource>(step.ExecutionContext).AsBoolean();
try
{
drainQueuesAfterTask = AgentKnobs.DrainQueuesAfterTask.GetValue(step.ExecutionContext).AsBooleanStrict();
}
catch { }

if (drainQueuesAfterTask == true)
{
try
{
Expand Down

0 comments on commit a1c0c67

Please sign in to comment.