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

Ensure agent does not receive new work in runOnce mode #2728

Merged
merged 2 commits into from
Jan 21, 2020
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
1 change: 1 addition & 0 deletions src/Agent.Listener/JobDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public void Run(Pipelines.AgentJobRequestMessage jobRequestMessage, bool runOnce
if (runOnce)
{
Trace.Info("Start dispatcher for one time used agent.");
jobRequestMessage.Variables[Constants.Variables.Agent.RunMode] = new VariableValue(Constants.Agent.CommandLine.Flags.Once);
newDispatch.WorkerDispatch = RunOnceAsync(jobRequestMessage, currentDispatch, newDispatch.WorkerCancellationTokenSource.Token, newDispatch.WorkerCancelTimeoutKillTokenSource.Token);
}
else
Expand Down
3 changes: 2 additions & 1 deletion src/Agent.Worker/JobRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,8 @@ private async Task<TaskResult> CompleteJobAsync(IJobServer jobServer, IExecution
}

Trace.Info("Raising job completed event.");
var jobCompletedEvent = new JobCompletedEvent(message.RequestId, message.JobId, result);
var jobCompletedEvent = new JobCompletedEvent(message.RequestId, message.JobId, result,
jobContext.Variables.Get(Constants.Variables.Agent.RunMode) == Constants.Agent.CommandLine.Flags.Once);

var completeJobRetryLimit = 5;
var exceptions = new List<Exception>();
Expand Down
2 changes: 1 addition & 1 deletion src/Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<OSPlatform>OS_UNKNOWN</OSPlatform>
<OSArchitecture>ARCH_UNKNOWN</OSArchitecture>
<DebugConstant></DebugConstant>
<VssApiVersion>0.5.147-private</VssApiVersion>
<VssApiVersion>0.5.148-private</VssApiVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.VisualStudio.Services.Agent/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ public static class Agent
public static readonly string RetainDefaultEncoding = "agent.retainDefaultEncoding";
public static readonly string ReadOnlyVariables = "agent.readOnlyVariables";
public static readonly string RootDirectory = "agent.RootDirectory";
public static readonly string RunMode = "agent.runMode";
public static readonly string ServerOMDirectory = "agent.ServerOMDirectory";
public static readonly string ServicePortPrefix = "agent.services";
public static readonly string SslCAInfo = "agent.cainfo";
Expand Down Expand Up @@ -450,6 +451,7 @@ public static class Task
Agent.RetainDefaultEncoding,
Agent.ReadOnlyVariables,
Agent.RootDirectory,
Agent.RunMode,
Agent.ServerOMDirectory,
Agent.ServicePortPrefix,
Agent.SslCAInfo,
Expand Down