Skip to content

Commit

Permalink
Remove AZP_AGENT_MOUNT_WORKSPACE knob (#4906)
Browse files Browse the repository at this point in the history
* Remove AZP_AGENT_MOUNT_WORKSPACE knob

* add :
  • Loading branch information
DenisRumyantsev authored Jul 26, 2024
1 parent 81050b4 commit 842df8d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 36 deletions.
7 changes: 0 additions & 7 deletions src/Agent.Sdk/Knob/AgentKnobs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -652,13 +652,6 @@ public class AgentKnobs
new RuntimeKnobSource("AZP_AGENT_CHECK_IF_TASK_NODE_RUNNER_IS_DEPRECATED"),
new BuiltInDefaultKnobSource("false"));

public static readonly Knob MountWorkspace = new Knob(
nameof(MountWorkspace),
"If true, the agent will mount the Pipeline.Workspace directory instead of the Working directory for steps which target a Docker container.",
new RuntimeKnobSource("AZP_AGENT_MOUNT_WORKSPACE"),
new EnvironmentKnobSource("AZP_AGENT_MOUNT_WORKSPACE"),
new BuiltInDefaultKnobSource("false"));

public static readonly Knob EnableNewSecretMasker = new Knob(
nameof(EnableNewSecretMasker),
"If true, the agent will use new SecretMasker with additional filters & performance enhancements",
Expand Down
34 changes: 6 additions & 28 deletions src/Agent.Worker/ContainerOperationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -483,34 +483,12 @@ private async Task StartContainerAsync(IExecutionContext executionContext, Conta

if (container.ImageOS != PlatformUtil.OS.Windows)
{
if (AgentKnobs.MountWorkspace.GetValue(executionContext).AsBoolean())
{
string workspace = executionContext.Variables.Get(Constants.Variables.Pipeline.Workspace);
workspace = container.TranslateContainerPathForImageOS(PlatformUtil.HostOS, container.TranslateToContainerPath(workspace));
string mountWorkspace = container.TranslateToHostPath(workspace);
executionContext.Debug($"Workspace {workspace}");
executionContext.Debug($"Mount Workspace {mountWorkspace}");
container.MountVolumes.Add(new MountVolume(mountWorkspace, workspace, readOnly: container.isReadOnlyVolume(Constants.DefaultContainerMounts.Work)));
}
else
{
string defaultWorkingDirectory = executionContext.Variables.Get(Constants.Variables.System.DefaultWorkingDirectory);
defaultWorkingDirectory = container.TranslateContainerPathForImageOS(PlatformUtil.HostOS, container.TranslateToContainerPath(defaultWorkingDirectory));
if (string.IsNullOrEmpty(defaultWorkingDirectory))
{
throw new NotSupportedException(StringUtil.Loc("ContainerJobRequireSystemDefaultWorkDir"));
}

string workingDirectory = IOUtil.GetDirectoryName(defaultWorkingDirectory.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar), container.ImageOS);
string mountWorkingDirectory = container.TranslateToHostPath(workingDirectory);
executionContext.Debug($"Default Working Directory {defaultWorkingDirectory}");
executionContext.Debug($"Working Directory {workingDirectory}");
executionContext.Debug($"Mount Working Directory {mountWorkingDirectory}");
if (!string.IsNullOrEmpty(workingDirectory))
{
container.MountVolumes.Add(new MountVolume(mountWorkingDirectory, workingDirectory, readOnly: container.isReadOnlyVolume(Constants.DefaultContainerMounts.Work)));
}
}
string workspace = executionContext.Variables.Get(Constants.Variables.Pipeline.Workspace);
workspace = container.TranslateContainerPathForImageOS(PlatformUtil.HostOS, container.TranslateToContainerPath(workspace));
string mountWorkspace = container.TranslateToHostPath(workspace);
executionContext.Debug($"Workspace: {workspace}");
executionContext.Debug($"Mount Workspace: {mountWorkspace}");
container.MountVolumes.Add(new MountVolume(mountWorkspace, workspace, readOnly: container.isReadOnlyVolume(Constants.DefaultContainerMounts.Work)));

container.MountVolumes.Add(new MountVolume(HostContext.GetDirectory(WellKnownDirectory.Temp), container.TranslateToContainerPath(HostContext.GetDirectory(WellKnownDirectory.Temp))));
container.MountVolumes.Add(new MountVolume(HostContext.GetDirectory(WellKnownDirectory.Tasks), container.TranslateToContainerPath(HostContext.GetDirectory(WellKnownDirectory.Tasks)),
Expand Down
1 change: 0 additions & 1 deletion src/Misc/layoutbin/en-US/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@
"ConnectingToServer": "Connecting to server ...",
"ConnectSectionHeader": "Connect",
"ConnectToServer": "Connecting to the server.",
"ContainerJobRequireSystemDefaultWorkDir": "System.DefaultWorkingDirectory is required for running a container job.",
"ContainerWindowsVersionRequirement": "Container feature requires Windows Server 1803 or higher. Please reference documentation (https://go.microsoft.com/fwlink/?linkid=875268)",
"CopyFileComplete": "Successfully published artifacts to {0}",
"CopyFileToDestination": "Copy file '{0}' to '{1}'",
Expand Down

0 comments on commit 842df8d

Please sign in to comment.