Skip to content
Open
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
26 changes: 15 additions & 11 deletions src/Agent.Worker/Container/DockerCommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,16 +270,7 @@ public async Task<int> DockerNetworkCreate(IExecutionContext context, string net

if (!String.IsNullOrEmpty(driver))
{
if (networkDrivers.Contains(driver))
{
options += $" --driver {driver}";
}
else
{
string warningMessage = $"Specified '{driver}' driver not found!";
Trace.Warning(warningMessage);
context.Warning(warningMessage);
}
options += $" --driver {driver}";
}
else if (usingWindowsContainers && networkDrivers.Contains("nat"))
{
Expand All @@ -291,7 +282,20 @@ public async Task<int> DockerNetworkCreate(IExecutionContext context, string net
options += $" {additionalNetworCreateOptions}";
}

return await ExecuteDockerCommandAsync(context, "network", options, context.CancellationToken);
// When originally introduced in #3751 the network driver check did automated fallback to "no network driver."
// In order to maintain that automated fallback behavior but not exclude custom network plugins we now attempt
// to create the network and, upon failure, retry with the network-driver-less invocation.
exitCode = await ExecuteDockerCommandAsync(context, "network", options, context.CancellationToken);
if (exitCode != 0)
{
string warningMessage = $"Specified '{driver}' driver not found! Retrying with unset driver.";
Trace.Warning(warningMessage);
context.Warning(warningMessage);
string networkDriverlessOptions = options.Replace($" --driver {driver}", "");
return await ExecuteDockerCommandAsync(context, "network", networkDriverlessOptions, context.CancellationToken)
}

return exitCode;
}

public async Task<int> DockerNetworkRemove(IExecutionContext context, string network)
Expand Down