From a4c87552b245e0b05d191c799e9cdc9ae2704d81 Mon Sep 17 00:00:00 2001 From: Denis Rumyantsev Date: Mon, 12 Aug 2024 13:32:51 +0200 Subject: [PATCH] Use node20_1 for sleepCommand when running container (#4929) --- src/Agent.Sdk/Knob/AgentKnobs.cs | 7 +++++++ src/Agent.Worker/ContainerOperationProvider.cs | 2 +- src/Agent.Worker/Handlers/NodeHandler.cs | 3 --- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Agent.Sdk/Knob/AgentKnobs.cs b/src/Agent.Sdk/Knob/AgentKnobs.cs index cff69085e7..d2658b5bfc 100644 --- a/src/Agent.Sdk/Knob/AgentKnobs.cs +++ b/src/Agent.Sdk/Knob/AgentKnobs.cs @@ -654,6 +654,13 @@ public class AgentKnobs new PipelineFeatureSource("CheckIfTaskNodeRunnerIsDeprecated"), new BuiltInDefaultKnobSource("false")); + public static readonly Knob UseNode20ToStartContainer = new Knob( + nameof(UseNode20ToStartContainer), + "If true, the agent will use Node 20 to start docker container when executing container job and the container platform is the same as the host platform.", + new RuntimeKnobSource("AZP_AGENT_USE_NODE20_TO_START_CONTAINER"), + new PipelineFeatureSource("UseNode20ToStartContainer"), + 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", diff --git a/src/Agent.Worker/ContainerOperationProvider.cs b/src/Agent.Worker/ContainerOperationProvider.cs index cd5c7344ad..68e9cecdbe 100644 --- a/src/Agent.Worker/ContainerOperationProvider.cs +++ b/src/Agent.Worker/ContainerOperationProvider.cs @@ -539,7 +539,7 @@ private async Task StartContainerAsync(IExecutionContext executionContext, Conta } else { - node = container.TranslateToContainerPath(Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Externals), "node", "bin", $"node{IOUtil.ExeExtension}")); + node = container.TranslateToContainerPath(Path.Combine(HostContext.GetDirectory(WellKnownDirectory.Externals), AgentKnobs.UseNode20ToStartContainer.GetValue(executionContext).AsBoolean() ? NodeHandler.Node20_1Folder : NodeHandler.NodeFolder, "bin", $"node{IOUtil.ExeExtension}")); // if on Mac OS X, require container to have node if (PlatformUtil.RunningOnMacOS) diff --git a/src/Agent.Worker/Handlers/NodeHandler.cs b/src/Agent.Worker/Handlers/NodeHandler.cs index 7be1cb6c4e..b96712c559 100644 --- a/src/Agent.Worker/Handlers/NodeHandler.cs +++ b/src/Agent.Worker/Handlers/NodeHandler.cs @@ -13,9 +13,6 @@ using System.Linq; using System.Collections.Generic; using System.Threading; -using Microsoft.TeamFoundation.Common.Internal; -using Microsoft.VisualStudio.Services.Agent.Worker.Telemetry; -using Newtonsoft.Json; using StringUtil = Microsoft.VisualStudio.Services.Agent.Util.StringUtil; namespace Microsoft.VisualStudio.Services.Agent.Worker.Handlers