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

Removed code related to local runner concept #2687

Merged
merged 3 commits into from Jan 7, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 0 additions & 15 deletions docs/preview/outdated/yamldeserialization.md
Expand Up @@ -141,21 +141,6 @@ For example, a process template can reference a phases template. A process templ

### TODO: Discuss overrides and selectors

## Run local

A goal of the agent is to support "run-local" mode for testing YAML configuration. When running local, all agent calls to the VSTS server are stubbed (and server URL is hardcoded to 127.0.0.1).

When running local, the YAML will be converted into a pipeline, and worker processes invoked for each job.

A definition variable `Agent.RunMode`=`Local` is added to each job.

Note, this is not fully implemented yet. Only task steps are supported. Sync-sources and resource-import/export are not supported yet. Each job is run with syncSources=false.

Example:
```
~/vsts-agent/_layout/bin/Agent.Listener --whatif --yaml ~/vsts-agent/docs/preview/yaml/cmdline.yaml
```

### What-if mode

A "what-if" mode is supported for debugging the YAML static expansion and deserialization process. What-if mode dumps the constructed pipeline to the console, and exits.
Expand Down
64 changes: 0 additions & 64 deletions docs/preview/outdated/yamlgettingstarted-localrun.md

This file was deleted.

25 changes: 2 additions & 23 deletions src/Agent.Listener/CommandSettings.cs
Expand Up @@ -20,7 +20,6 @@ public sealed class CommandSettings
private readonly string[] validCommands =
{
Constants.Agent.CommandLine.Commands.Configure,
Constants.Agent.CommandLine.Commands.LocalRun,
Constants.Agent.CommandLine.Commands.Remove,
Constants.Agent.CommandLine.Commands.Run,
Constants.Agent.CommandLine.Commands.Warmup,
Expand All @@ -47,8 +46,7 @@ public sealed class CommandSettings
Constants.Agent.CommandLine.Flags.Once,
Constants.Agent.CommandLine.Flags.SslSkipCertValidation,
Constants.Agent.CommandLine.Flags.Unattended,
Constants.Agent.CommandLine.Flags.Version,
Constants.Agent.CommandLine.Flags.WhatIf
Constants.Agent.CommandLine.Flags.Version
};

private readonly string[] validArgs =
Expand All @@ -67,7 +65,6 @@ public sealed class CommandSettings
Constants.Agent.CommandLine.Args.MonitorSocketAddress,
Constants.Agent.CommandLine.Args.NotificationPipeName,
Constants.Agent.CommandLine.Args.Password,
Constants.Agent.CommandLine.Args.Phase,
Constants.Agent.CommandLine.Args.Pool,
Constants.Agent.CommandLine.Args.ProjectName,
Constants.Agent.CommandLine.Args.ProxyPassword,
Expand All @@ -84,13 +81,11 @@ public sealed class CommandSettings
Constants.Agent.CommandLine.Args.UserName,
Constants.Agent.CommandLine.Args.WindowsLogonAccount,
Constants.Agent.CommandLine.Args.WindowsLogonPassword,
Constants.Agent.CommandLine.Args.Work,
Constants.Agent.CommandLine.Args.Yml
Constants.Agent.CommandLine.Args.Work
};

// Commands.
public bool Configure => TestCommand(Constants.Agent.CommandLine.Commands.Configure);
public bool LocalRun => TestCommand(Constants.Agent.CommandLine.Commands.LocalRun);
public bool Remove => TestCommand(Constants.Agent.CommandLine.Commands.Remove);
public bool Run => TestCommand(Constants.Agent.CommandLine.Commands.Run);
public bool Warmup => TestCommand(Constants.Agent.CommandLine.Commands.Warmup);
Expand All @@ -103,7 +98,6 @@ public sealed class CommandSettings
public bool DeploymentGroup => TestFlag(Constants.Agent.CommandLine.Flags.MachineGroup) || TestFlag(Constants.Agent.CommandLine.Flags.DeploymentGroup);
public bool DeploymentPool => TestFlag(Constants.Agent.CommandLine.Flags.DeploymentPool);
public bool EnvironmentVMResource => TestFlag(Constants.Agent.CommandLine.Flags.Environment);
public bool WhatIf => TestFlag(Constants.Agent.CommandLine.Flags.WhatIf);
public bool GitUseSChannel => TestFlag(Constants.Agent.CommandLine.Flags.GitUseSChannel);
public bool RunOnce => TestFlag(Constants.Agent.CommandLine.Flags.Once);

Expand Down Expand Up @@ -258,11 +252,6 @@ public string GetAuth(string defaultValue)
validator: Validators.AuthSchemeValidator);
}

public string GetMatrix()
{
return GetArg(Constants.Agent.CommandLine.Args.Matrix);
}

public string GetPassword()
{
return GetArgOrPrompt(
Expand All @@ -272,11 +261,6 @@ public string GetPassword()
validator: Validators.NonEmptyValidator);
}

public string GetPhase()
{
return GetArg(Constants.Agent.CommandLine.Args.Phase);
}

public string GetPool()
{
return GetArgOrPrompt(
Expand Down Expand Up @@ -462,11 +446,6 @@ public string GetStartupType()
return GetArg(Constants.Agent.CommandLine.Args.StartupType);
}

public string GetYml()
{
return GetArg(Constants.Agent.CommandLine.Args.Yml);
}

public string GetProxyUrl()
{
return GetArg(Constants.Agent.CommandLine.Args.ProxyUrl);
Expand Down
2 changes: 0 additions & 2 deletions src/Agent.Listener/Configuration/ConfigurationManager.cs
Expand Up @@ -66,7 +66,6 @@ public AgentSettings LoadSettings()

public async Task ConfigureAsync(CommandSettings command)
{
ArgUtil.Equal(RunMode.Normal, HostContext.RunMode, nameof(HostContext.RunMode));
Trace.Info(nameof(ConfigureAsync));
if (IsConfigured())
{
Expand Down Expand Up @@ -485,7 +484,6 @@ public async Task ConfigureAsync(CommandSettings command)

public async Task UnconfigureAsync(CommandSettings command)
{
ArgUtil.Equal(RunMode.Normal, HostContext.RunMode, nameof(HostContext.RunMode));
string currentAction = string.Empty;
try
{
Expand Down
50 changes: 16 additions & 34 deletions src/Agent.Listener/JobDispatcher.cs
Expand Up @@ -25,7 +25,6 @@ public interface IJobDispatcher : IAgentService
void Run(Pipelines.AgentJobRequestMessage message, bool runOnce = false);
bool Cancel(JobCancelMessage message);
Task WaitAsync(CancellationToken token);
TaskResult GetLocalRunJobResult(AgentJobRequestMessage message);
Task ShutdownAsync();
}

Expand Down Expand Up @@ -168,11 +167,6 @@ public async Task WaitAsync(CancellationToken token)
}
}

public TaskResult GetLocalRunJobResult(AgentJobRequestMessage message)
{
return _localRunJobResult.Value[message.RequestId];
}

public async Task ShutdownAsync()
{
Trace.Info($"Shutting down JobDispatcher. Make sure all WorkerDispatcher has finished.");
Expand Down Expand Up @@ -376,37 +370,30 @@ private async Task RunAsync(Pipelines.AgentJobRequestMessage message, WorkerDisp
ArgUtil.NotNullOrEmpty(pipeHandleOut, nameof(pipeHandleOut));
ArgUtil.NotNullOrEmpty(pipeHandleIn, nameof(pipeHandleIn));

if (HostContext.RunMode == RunMode.Normal)
// Save STDOUT from worker, worker will use STDOUT report unhandle exception.
processInvoker.OutputDataReceived += delegate (object sender, ProcessDataReceivedEventArgs stdout)
{
// Save STDOUT from worker, worker will use STDOUT report unhandle exception.
processInvoker.OutputDataReceived += delegate (object sender, ProcessDataReceivedEventArgs stdout)
if (!string.IsNullOrEmpty(stdout.Data))
{
if (!string.IsNullOrEmpty(stdout.Data))
lock (_outputLock)
{
lock (_outputLock)
{
workerOutput.Add(stdout.Data);
}
workerOutput.Add(stdout.Data);
}
};
}
};

// Save STDERR from worker, worker will use STDERR on crash.
processInvoker.ErrorDataReceived += delegate (object sender, ProcessDataReceivedEventArgs stderr)
// Save STDERR from worker, worker will use STDERR on crash.
processInvoker.ErrorDataReceived += delegate (object sender, ProcessDataReceivedEventArgs stderr)
{
if (!string.IsNullOrEmpty(stderr.Data))
{
if (!string.IsNullOrEmpty(stderr.Data))
lock (_outputLock)
{
lock (_outputLock)
{
workerOutput.Add(stderr.Data);
}
workerOutput.Add(stderr.Data);
}
};
}
else if (HostContext.RunMode == RunMode.Local)
{
processInvoker.OutputDataReceived += (object sender, ProcessDataReceivedEventArgs e) => Console.WriteLine(e.Data);
processInvoker.ErrorDataReceived += (object sender, ProcessDataReceivedEventArgs e) => Console.WriteLine(e.Data);
}
}
};


// Start the child process.
HostContext.WritePerfCounter("StartingWorkerProcess");
Expand Down Expand Up @@ -754,11 +741,6 @@ public async Task RenewJobRequestAsync(int poolId, long requestId, Guid lockToke
private async Task CompleteJobRequestAsync(int poolId, Pipelines.AgentJobRequestMessage message, Guid lockToken, TaskResult result, string detailInfo = null)
{
Trace.Entering();
if (HostContext.RunMode == RunMode.Local)
{
_localRunJobResult.Value[message.RequestId] = result;
return;
}

if (PlanUtil.GetFeatures(message.Plan).HasFlag(PlanFeatures.JobCompletedPlanEvent))
{
Expand Down