Skip to content
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
12 changes: 7 additions & 5 deletions src/Agent.Worker/NodeVersionStrategies/Node10Strategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Agent.Sdk;
using Agent.Sdk.Knob;
using Microsoft.TeamFoundation.DistributedTask.WebApi;
using Microsoft.VisualStudio.Services.Agent;
using Microsoft.VisualStudio.Services.Agent.Util;
using Microsoft.VisualStudio.Services.Agent.Worker;

Expand All @@ -20,7 +21,7 @@ public NodeRunnerInfo CanHandle(TaskContext context, IExecutionContext execution

if (hasNode10Handler)
{
return DetermineNodeVersionSelection(context, eolPolicyEnabled, "Selected for Node10 task handler");
return DetermineNodeVersionSelection(context, eolPolicyEnabled, "Selected for Node10 task handler", executionContext);
}

bool isAlpine = PlatformUtil.RunningOnAlpine;
Expand All @@ -30,14 +31,15 @@ public NodeRunnerInfo CanHandle(TaskContext context, IExecutionContext execution
"Using Node10 on Alpine Linux because Node6 is not compatible. " +
"Node10 has reached End-of-Life. Please upgrade to Node20 or Node24 for continued support.");

return DetermineNodeVersionSelection(context, eolPolicyEnabled, "Selected for Alpine Linux compatibility (Node6 incompatible)");
return DetermineNodeVersionSelection(context, eolPolicyEnabled, "Selected for Alpine Linux compatibility (Node6 incompatible)", executionContext);
}

return null;
}

private NodeRunnerInfo DetermineNodeVersionSelection(TaskContext context, bool eolPolicyEnabled, string baseReason)
private NodeRunnerInfo DetermineNodeVersionSelection(TaskContext context, bool eolPolicyEnabled, string baseReason, IExecutionContext executionContext)
{
string taskName = executionContext.Variables.Get(Constants.Variables.Task.DisplayName) ?? "Unknown Task";
if (eolPolicyEnabled)
{
throw new NotSupportedException(StringUtil.Loc("NodeEOLPolicyBlocked", "Node10"));
Expand All @@ -48,9 +50,9 @@ private NodeRunnerInfo DetermineNodeVersionSelection(TaskContext context, bool e
NodePath = null,
NodeVersion = NodeVersion.Node10,
Reason = baseReason,
Warning = StringUtil.Loc("NodeEOLWarning", "Node10")
Warning = StringUtil.Loc("NodeEOLRetirementWarning", taskName)
};
}

}
}
8 changes: 5 additions & 3 deletions src/Agent.Worker/NodeVersionStrategies/Node16Strategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.IO;
using Agent.Sdk.Knob;
using Microsoft.TeamFoundation.DistributedTask.WebApi;
using Microsoft.VisualStudio.Services.Agent;
using Microsoft.VisualStudio.Services.Agent.Util;
using Microsoft.VisualStudio.Services.Agent.Worker;
using Microsoft.VisualStudio.Services.Agent.Worker.Container;
Expand All @@ -20,14 +21,15 @@ public NodeRunnerInfo CanHandle(TaskContext context, IExecutionContext execution

if (hasNode16Handler)
{
return DetermineNodeVersionSelection(context, eolPolicyEnabled, "Selected for Node16 task handler");
return DetermineNodeVersionSelection(context, eolPolicyEnabled, "Selected for Node16 task handler", executionContext);
}

return null;
}

private NodeRunnerInfo DetermineNodeVersionSelection(TaskContext context, bool eolPolicyEnabled, string baseReason)
private NodeRunnerInfo DetermineNodeVersionSelection(TaskContext context, bool eolPolicyEnabled, string baseReason, IExecutionContext executionContext)
{
string taskName = executionContext.Variables.Get(Constants.Variables.Task.DisplayName) ?? "Unknown Task";
if (eolPolicyEnabled)
{
throw new NotSupportedException(StringUtil.Loc("NodeEOLPolicyBlocked", "Node16"));
Expand All @@ -38,7 +40,7 @@ private NodeRunnerInfo DetermineNodeVersionSelection(TaskContext context, bool e
NodePath = null,
NodeVersion = NodeVersion.Node16,
Reason = baseReason,
Warning = StringUtil.Loc("NodeEOLWarning", "Node16")
Warning = StringUtil.Loc("NodeEOLRetirementWarning", taskName)
};
}

Expand Down
15 changes: 9 additions & 6 deletions src/Agent.Worker/NodeVersionStrategies/Node20Strategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,35 @@ public NodeRunnerInfo CanHandle(TaskContext context, IExecutionContext execution

if (useNode20Globally)
{
return DetermineNodeVersionSelection(context, eolPolicyEnabled, "Selected via global AGENT_USE_NODE20_1 override", glibcInfo);
return DetermineNodeVersionSelection(context, eolPolicyEnabled, "Selected via global AGENT_USE_NODE20_1 override", executionContext, glibcInfo);
}

if (hasNode20Handler)
{
return DetermineNodeVersionSelection(context, eolPolicyEnabled, "Selected for Node20 task handler", glibcInfo);
return DetermineNodeVersionSelection(context, eolPolicyEnabled, "Selected for Node20 task handler", executionContext, glibcInfo);
}

if (eolPolicyEnabled)
{
return DetermineNodeVersionSelection(context, eolPolicyEnabled, "Upgraded from end-of-life Node version due to EOL policy", glibcInfo);
return DetermineNodeVersionSelection(context, eolPolicyEnabled, "Upgraded from end-of-life Node version due to EOL policy", executionContext, glibcInfo, isUpgradeScenario: true);
}

return null;
}

private NodeRunnerInfo DetermineNodeVersionSelection(TaskContext context, bool eolPolicyEnabled, string baseReason, GlibcCompatibilityInfo glibcInfo)
private NodeRunnerInfo DetermineNodeVersionSelection(TaskContext context, bool eolPolicyEnabled, string baseReason, IExecutionContext executionContext, GlibcCompatibilityInfo glibcInfo, bool isUpgradeScenario = false)
{
string taskName = executionContext.Variables.Get(Constants.Variables.Task.DisplayName) ?? "Unknown Task";
string upgradeWarning = isUpgradeScenario ? StringUtil.Loc("NodeEOLUpgradeWarning", taskName) : null;

if (!glibcInfo.Node20HasGlibcError)
{
return new NodeRunnerInfo
{
NodePath = null,
NodeVersion = NodeVersion.Node20,
Reason = baseReason,
Warning = null
Warning = upgradeWarning
};
}

Expand All @@ -62,7 +65,7 @@ private NodeRunnerInfo DetermineNodeVersionSelection(TaskContext context, bool e
NodePath = null,
NodeVersion = NodeVersion.Node16,
Reason = $"{baseReason}, fallback to Node16 due to Node20 glibc compatibility issue",
Warning = StringUtil.Loc("NodeGlibcFallbackWarning", systemType, "Node20", "Node16")
Warning = StringUtil.Loc("NodeEOLRetirementWarning", taskName)
};
}

Expand Down
18 changes: 12 additions & 6 deletions src/Agent.Worker/NodeVersionStrategies/Node24Strategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Agent.Sdk;
using Agent.Sdk.Knob;
using Microsoft.TeamFoundation.DistributedTask.WebApi;
using Microsoft.VisualStudio.Services.Agent;
using Microsoft.VisualStudio.Services.Agent.Util;
using Microsoft.VisualStudio.Services.Agent.Worker;
using Microsoft.VisualStudio.Services.Agent.Worker.Container;
Expand Down Expand Up @@ -64,7 +65,7 @@ public NodeRunnerInfo CanHandle(TaskContext context, IExecutionContext execution

if (eolPolicyEnabled)
{
return DetermineNodeVersionSelection(context, eolPolicyEnabled, "Upgraded from end-of-life Node version due to EOL policy", executionContext, glibcInfo, skipNode24Check: false);
return DetermineNodeVersionSelection(context, eolPolicyEnabled, "Upgraded from end-of-life Node version due to EOL policy", executionContext, glibcInfo, skipNode24Check: false, isUpgradeScenario: true);
}

return null;
Expand All @@ -74,9 +75,11 @@ public NodeRunnerInfo CanHandle(TaskContext context, IExecutionContext execution
/// Determines the appropriate Node version based on glibc compatibility and EOL policy.
/// </summary>
/// <param name="skipNode24Check">When true, skips checking Node24 glibc (used when Node24 folder doesn't exist)</param>
private NodeRunnerInfo DetermineNodeVersionSelection(TaskContext context, bool eolPolicyEnabled, string baseReason, IExecutionContext executionContext, GlibcCompatibilityInfo glibcInfo, bool skipNode24Check)
private NodeRunnerInfo DetermineNodeVersionSelection(TaskContext context, bool eolPolicyEnabled, string baseReason, IExecutionContext executionContext, GlibcCompatibilityInfo glibcInfo, bool skipNode24Check, bool isUpgradeScenario = false)
{
string systemType = context.Container != null ? "container" : "agent";
string taskName = executionContext.Variables.Get(Constants.Variables.Task.DisplayName) ?? "Unknown Task";
string upgradeWarning = isUpgradeScenario ? StringUtil.Loc("NodeEOLUpgradeWarning", taskName) : null;

if (!skipNode24Check && !glibcInfo.Node24HasGlibcError)
{
Expand All @@ -85,19 +88,22 @@ private NodeRunnerInfo DetermineNodeVersionSelection(TaskContext context, bool e
NodePath = null,
NodeVersion = NodeVersion.Node24,
Reason = baseReason,
Warning = null
Warning = upgradeWarning
};
}

if (!glibcInfo.Node20HasGlibcError)
{
string fallbackReason = skipNode24Check
? $"{baseReason}, fallback to Node20 because Node24 is not available"
: $"{baseReason}, fallback to Node20 due to Node24 glibc compatibility issue";

return new NodeRunnerInfo
{
NodePath = null,
NodeVersion = NodeVersion.Node20,
Reason = $"{baseReason}, fallback to Node20 due to Node24 glibc compatibility issue",
Warning = StringUtil.Loc("NodeGlibcFallbackWarning", systemType, "Node24", "Node20")
Reason = fallbackReason,
Warning = upgradeWarning ?? StringUtil.Loc("NodeGlibcFallbackWarning", systemType, "Node24", "Node20")
};
}

Expand All @@ -115,7 +121,7 @@ private NodeRunnerInfo DetermineNodeVersionSelection(TaskContext context, bool e
NodePath = null,
NodeVersion = NodeVersion.Node16,
Reason = $"{baseReason}, fallback to Node16 due to both Node24 and Node20 glibc compatibility issues",
Warning = StringUtil.Loc("NodeGlibcFallbackWarning", systemType, "Node24 or Node20", "Node16")
Warning = StringUtil.Loc("NodeEOLRetirementWarning", taskName)
};
}

Expand Down
10 changes: 6 additions & 4 deletions src/Agent.Worker/NodeVersionStrategies/Node6Strategy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.IO;
using Agent.Sdk.Knob;
using Microsoft.TeamFoundation.DistributedTask.WebApi;
using Microsoft.VisualStudio.Services.Agent;
using Microsoft.VisualStudio.Services.Agent.Util;
using Microsoft.VisualStudio.Services.Agent.Worker;

Expand All @@ -20,25 +21,26 @@ public NodeRunnerInfo CanHandle(TaskContext context, IExecutionContext execution

if (hasNode6Handler)
{
return DetermineNodeVersionSelection(context, eolPolicyEnabled, "Selected for Node6 task handler");
return DetermineNodeVersionSelection(context, eolPolicyEnabled, "Selected for Node6 task handler", executionContext);
}

return null;
}

private NodeRunnerInfo DetermineNodeVersionSelection(TaskContext context, bool eolPolicyEnabled, string baseReason)
private NodeRunnerInfo DetermineNodeVersionSelection(TaskContext context, bool eolPolicyEnabled, string baseReason, IExecutionContext executionContext)
{
string taskName = executionContext.Variables.Get(Constants.Variables.Task.DisplayName) ?? "Unknown Task";
if (eolPolicyEnabled)
{
throw new NotSupportedException(StringUtil.Loc("NodeEOLPolicyBlocked", "Node6"));
}

return new NodeRunnerInfo
{
NodePath = null,
NodeVersion = NodeVersion.Node6,
Reason = baseReason,
Warning = StringUtil.Loc("NodeEOLWarning", "Node6")
Warning = StringUtil.Loc("NodeEOLRetirementWarning", taskName)
};
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/Misc/layoutbin/en-US/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,8 @@
"NoArtifactsFound": "No artifacts are available in the version '{0}'.",
"NodeEOLFallbackBlocked": "would fallback to {1} (EOL) but EOL policy is enabled",
"NodeEOLPolicyBlocked": "Task requires {0} which has reached End-of-Life. This is blocked by organization policy. Please upgrade task to Node20 or Node24. To temporarily disable this check: Set AGENT_RESTRICT_EOL_NODE_VERSIONS=false",
"NodeEOLWarning": "{0} has reached End-of-Life. Please upgrade to Node20 or Node24.",
"NodeEOLRetirementWarning": "Task {0} relies on an unsupported version of Node.js. Unsupported Node versions (6, 10, and 16) are being retired, and any pipelines using tasks dependent on these versions will begin to fail. Learn More https://aka.ms/node-runner-guidance",
"NodeEOLUpgradeWarning": "Task {0} relies on an unsupported version of Node.js. To avoid use of unsupported Node.js the task is being run on the latest available version of Node.js. The task may fail or work unexpectedly. Learn More https://aka.ms/node-runner-guidance",
"NodeGlibcFallbackWarning": "The {0} operating system doesn't support {1}. Using {2} instead. Please upgrade the operating system to remain compatible with future updates.",
"NodeVersionNotAvailable": "No compatible Node.js version available for host execution. Handler type: {0}. This may occur if all available versions are blocked by EOL policy. Please update your pipeline to use Node20 or Node24 tasks. To temporarily disable EOL policy: Set AGENT_RESTRICT_EOL_NODE_VERSIONS=false",
"NoFolderToClean": "Specified cleaning folder was not found. Nothing to clean",
Expand Down
Loading