Skip to content

Conversation

@surajitshil-03
Copy link
Contributor

@surajitshil-03 surajitshil-03 commented Jan 28, 2026

Context

This PR addresses a Node.js version fallback issue on platforms where certain Node versions are not available (e.g., win-x86 where Node24 binaries are not shipped). Currently, when a task requests Node24 but the binary doesn't exist on the platform, the agent fails instead of gracefully falling back to an available Node version (Node20 or Node16).

Related repair-item: AB#2351680


Description

  1. Legacy node selection:
  • Added IsNodeFolderExist() check in GetNodeFolderWithFallback() to detect when Node24/Node20 binaries are missing
  • Implemented fallback chain: Node24 → Node20 → Node16 when binaries don't exist
  • Added PublishNodeFallbackTelemetry() to track fallback scenarios
  • Updated warning messages to indicate platform availability issues
  1. Node selection based on strategy pattern:
  • Added IsNodeFolderExist() check at the start of each strategy's CanHandle() method
  • Node20Strategy now handles Node24HandlerData tasks as fallback when Node24Strategy returns null
  • Node16Strategy now handles both Node24HandlerData and Node20HandlerData tasks as fallback
  • Added telemetry publishing for fallback scenarios in each strategy
  • Added appropriate warning messages with architecture information

Risk Assessment (Low / Medium / High)

Medium

  • Code path sensitivity: Node handler selection is a critical path for all Node-based tasks
  • Backward compatibility: Existing behavior is preserved when Node binaries exist; fallback only activates when binaries are missing

Unit Tests Added or Updated (Yes / No)

Updated NodeHandlerTestBase.cs to register INodeHandlerHelper mock via SetSingleton, enabling proper testing of Node24 fallback scenarios when the Node24 binary is not available on certain platforms (e.g., win-x86).


Additional Testing Performed

Manually tested the scenario in iwin-x64 machine without node 24 and the fallback is happening as expected:
image


Change Behind Feature Flag (Yes / No)

Can this change be behine feature flag, if not why?


Tech Design / Approach

  • In legacy node selection process we have added the IsNodeFolderExist() check which now checks whether the node exist or not before checking for glibc errors.
  • In strategy pattern selection process we are using the nodehandler info for the higher priority nodes in subsequent/fallback node strategies to fallback properly.

Documentation Changes Required (Yes/No)

No


Logging Added/Updated (Yes/No)

Yes
Debug logs added for fallback decision points (e.g., "[Node24Strategy] Node24 binary not available on this platform, returning null for fallback")


Telemetry Added/Updated (Yes/No)

Yes
New fallback telemetry published via PublishNodeFallbackTelemetry() includes:

  • RequestedNodeVersion - The originally requested Node version

  • FallbackNodeVersion - The version being used instead

  • FallbackReason - Why fallback occurred (NodeNotAvailable, GlibCError)

  • Architecture - Process architecture (x86, x64, ARM64)

  • , OSName, OSVersion - Platform information

  • Strategy - Which strategy handled the fallback

  • JobId, PlanId, AgentName, AgentVersion, IsSelfHosted


Rollback Scenario and Process (Yes/No)

Revert to older agent versions or revert the changes in the code and release a new agent.


Dependency Impact Assessed and Regression Tested (Yes/No)

  • All impacted internal modules, APIs, services, and third-party libraries are analyzed.
  • Results are reviewed and confirmed to not break existing functionality.

@surajitshil-03
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@surajitshil-03
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

}

// Handle Node24 tasks as fallback when Node24Strategy and Node20Strategy returned null
if (hasNode24Handler)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this required here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

return result;
}

private bool IsNodeFolderExist(string nodeFolderName, IExecutionContext executionContext)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be part of some helper class as this is required in all strategy classes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used the already implemented method for checking existence of node folder

return File.Exists(nodePath);
}

private void PublishNodeFallbackTelemetry(IExecutionContext executionContext, string requestedNodeVersion, string fallbackReason, TaskContext context, string fallbackNodeVersion = null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should also be part of some helper class

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used the telemetry class used in the main orchestrator file

@surajitshil-03
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@surajitshil-03 surajitshil-03 marked this pull request as ready for review January 29, 2026 09:55
@surajitshil-03 surajitshil-03 requested review from a team as code owners January 29, 2026 09:55
@surajitshil-03 surajitshil-03 force-pushed the users/surajitshil/fixFallBack branch from 39e519c to 950edf2 Compare January 29, 2026 09:58
@surajitshil-03
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).


[ServiceLocator(Default = typeof(NodeHandlerHelper))]
public interface INodeHandlerHelper
public interface INodeHandlerHelper : IAgentService
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this added here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking this change if we can implement it in some other way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the changes but to avoid the testcases to fail I have created a new interface in the file INodeExistenceChecker.cs in which we have defined the method to check the node folder exists or not. Like in this way when the test cases will call this method then this will return true always because the test cases always expect to return true for node folder availability check.

@surajitshil-03
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants