Skip to content

Add NodeVersionStrategy support to ContainerOperationProviderEnhanced#5532

Open
rishabhmalikMS wants to merge 8 commits intomasterfrom
users/rishabhmalik/enhancedContainerProviderUpdate
Open

Add NodeVersionStrategy support to ContainerOperationProviderEnhanced#5532
rishabhmalikMS wants to merge 8 commits intomasterfrom
users/rishabhmalik/enhancedContainerProviderUpdate

Conversation

@rishabhmalikMS
Copy link
Copy Markdown
Contributor

@rishabhmalikMS rishabhmalikMS commented Apr 21, 2026

Context

Replicate the UseNodeVersionStrategy knob-gated code path from ContainerOperationProvider into ContainerOperationProviderEnhanced:

  • Read UseNodeVersionStrategy knob alongside existing node knobs

  • Gate container command: use sleep infinity/ping when enabled, legacy node-based startup in else branch

  • Add orchestrator branch after container start verification to select optimal node version via NodeVersionOrchestrator

  • Add GetJobContainerHandlerData and SetContainerNodePathWithOrchestrator private methods (verbatim copy from ContainerOperationProvider)

  • AB#2380695


Description

This PR adds UseNodeVersionStrategy support to ContainerOperationProviderEnhanced, bringing it to parity with
ContainerOperationProvider. When the UseNodeVersionStrategy knob is enabled:

  1. Container keepalive command no longer depends on Node.js being present inside the container. Instead it uses OS-native commands:
    - Linux containers: sleep infinity
    - Windows containers: cmd.exe /c timeout /t -1 /nobreak > nul
  2. Post-startup node selection uses NodeVersionOrchestrator to determine the optimal Node.js version for task execution, with a
    fallback to the legacy node path on failure.
  3. Legacy path preserved: When the knob is off (default), behavior is unchanged — the existing node-based setInterval keepalive and
    fallback chain remain intact.

Files changed:

  • ContainerOperationProviderEnhanced.cs — Added knob read, OS-based keepalive branching, orchestrator integration, and two new
    private methods
  • ContainerOperationProviderEnhancedL0.cs — Added 4 new L0 tests covering the UseNodeVersionStrategy path (with docker label,
    Windows+Linux container, Windows+Windows container, Linux native)
  • ContainerOperationProviderL0Base.cs — Added useNodeVersionStrategy parameter to CreateExecutionContextMock to control knob
    activation via Moq-specific matcher overrides

Risk Assessment (Low)

  • Feature-flagged: All changes are gated behind the existing UseNodeVersionStrategy knob (default: false). When the knob is off, zero
    code paths are affected.
  • No backward compatibility concerns: The legacy else-branch is unchanged. Existing container startup behavior is preserved exactly.
  • Scoped to enhanced provider only: Changes are isolated to ContainerOperationProviderEnhanced.cs, which is itself behind a separate
    knob.
  • Pattern already proven: The same logic has been running in ContainerOperationProvider (the standard provider) — this PR replicates that proven pattern.

Unit Tests Added or Updated (Yes / No)

  • 4 new L0 tests added to ContainerOperationProviderEnhancedL0.cs:
  • StartContainer_UseNodeVersionStrategy_WithDockerLabel_UsesSleepOrTimeout — verifies keepalive when container provides custom node
    via Docker label
  • StartContainer_UseNodeVersionStrategy_OnWindows_LinuxContainer_UsesSleepInfinity — Windows host + Linux container → sleep infinity
  • StartContainer_UseNodeVersionStrategy_OnWindows_WindowsContainer_UsesTimeout — Windows host + Windows container → timeout
  • StartContainer_UseNodeVersionStrategy_OnLinux_UsesSleepInfinity — Linux host + Linux container → sleep infinity
  • Base class updated: ContainerOperationProviderL0Base.CreateExecutionContextMock now accepts useNodeVersionStrategy parameter to
    activate the knob via specific Moq setup overrides on GetVariableValueOrDefault("AGENT_USE_NODE_STRATEGY")
  • All 4 existing legacy tests unchanged and passing

Additional Testing Performed

List manual or automated tests performed beyond unit tests (e.g., integration, scenario, regression).


Change Behind Feature Flag (Yes / No)

Yes


Tech Design / Approach

  • Design mirrors the existing implementation in ContainerOperationProvider for consistency and maintainability.

Documentation Changes Required (Yes/No)

Indicate whether related documentation needs to be updated.

  • User guides, API specs, system diagrams, or runbooks are updated.

Logging Added/Updated (Yes/No)

  • Appropriate log statements are added with meaningful messages.
  • Logging does not expose sensitive data.
  • Log levels are used correctly (e.g., info, warn, error).

Telemetry Added/Updated (Yes/No)

  • Custom telemetry (e.g., counters, timers, error tracking) is added as needed.
  • Events are tagged with proper metadata for filtering and analysis.
  • Telemetry is validated in staging or test environments.

Rollback Scenario and Process (Yes/No)

  • Rollback plan is documented.

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.

Replicate the UseNodeVersionStrategy knob-gated code path from
ContainerOperationProvider into ContainerOperationProviderEnhanced:

- Read UseNodeVersionStrategy knob alongside existing node knobs
- Gate container command: use sleep infinity/ping when enabled,
  legacy node-based startup in else branch
- Add orchestrator branch after container start verification to
  select optimal node version via NodeVersionOrchestrator
- Add GetJobContainerHandlerData and SetContainerNodePathWithOrchestrator
  private methods (verbatim copy from ContainerOperationProvider)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 1 pipeline(s).

@rishabhmalikMS
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 1 pipeline(s).

@rishabhmalikMS rishabhmalikMS marked this pull request as ready for review April 21, 2026 11:26
@rishabhmalikMS rishabhmalikMS requested review from a team as code owners April 21, 2026 11:26
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 1 pipeline(s).

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 1 pipeline(s).

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 1 pipeline(s).

@rishabhmalikMS
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 1 pipeline(s).

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 1 pipeline(s).

 Update ContainerOperationProviderEnhancedL0 tests to cover both legacy
 and UseNodeVersionStrategy code paths. Legacy tests verify node-based
 keepalive commands, while new tests verify OS-specific keepalive
 (sleep infinity for Linux, timeout for Windows) when the knob is enabled.

 Add useNodeVersionStrategy parameter to CreateExecutionContextMock in
 ContainerOperationProviderL0Base to control the AGENT_USE_NODE_STRATEGY
 knob via specific Moq matcher overrides, ensuring correct knob evaluation
 in test contexts.
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 1 pipeline(s).

@rishabhmalikMS
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 1 pipeline(s).

Comment thread src/Agent.Worker/ContainerOperationProviderEnhanced.cs Outdated
@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 1 pipeline(s).

@rishabhmalikMS
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 1 pipeline(s).

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 1 pipeline(s).

@rishabhmalikMS
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines:
Successfully started running 1 pipeline(s).

Comment thread src/Agent.Worker/ContainerOperationProviderEnhanced.cs
@rishabhmalikMS rishabhmalikMS enabled auto-merge (squash) April 22, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants