Skip to content

JobMonitor: Preserve DockerTag/QueueAlias when resubmitting work items - #16963

Merged
premun merged 2 commits into
dotnet:mainfrom
mmitche:dev/fix-resubmit-dockertag-16961
Jun 4, 2026
Merged

JobMonitor: Preserve DockerTag/QueueAlias when resubmitting work items#16963
premun merged 2 commits into
dotnet:mainfrom
mmitche:dev/fix-resubmit-dockertag-16961

Conversation

@mmitche

@mmitche mmitche commented Jun 3, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #16961.

When the JobMonitor resubmits failed Helix work items, it builds the JobCreationRequest using only the resolved QueueId from Job.DetailsAsync (which has the Docker tag and queue alias stripped). As a result, a work item that originally ran inside a Docker container was re-run on the bare host queue — the wrong execution environment.

Fix

The Helix SDK MSBuild targets stamp the original target queue string verbatim onto the job''s operatingSystem property (HelixProperties Include="operatingSystem" Value="$(HelixTargetQueue)" in Microsoft.DotNet.Helix.Sdk.MonoQueue.targets), in the (alias)queueId@dockerTag form. This is the same string the fresh submission path parses.

HelixService.ResubmitWorkItemsAsync now:

  • Reads the operatingSystem property and parses it with the same logic the fresh submission path uses (JobDefinition.ParseQueueId), setting QueueId, DockerTag, and QueueAlias consistently — matching what a fresh Helix SDK submission would send.
  • Falls back to the resolved QueueId with no Docker tag/alias when the property is absent or unparseable (preserving prior behavior).

This was validated to be the correct source of truth: Job.DetailsAsync does not expose DockerTag/QueueAlias, but the operatingSystem property is an exact copy of the original TargetQueue.

Tests

Added unit tests in HelixServiceTests covering:

  • Docker queue with alias → preserves QueueId, QueueAlias, DockerTag.
  • Docker queue without alias → preserves QueueId and DockerTag.
  • Non-Docker queue → sets QueueId/QueueAlias, empty DockerTag (mirrors fresh submission).
  • Missing/unparseable operatingSystem → falls back to resolved QueueId with null Docker tag/alias.

All 126 tests in Microsoft.DotNet.Helix.Sdk.Tests pass.

Notes

ResultContainerPrefix (also not copied on resubmission) is intentionally left out of scope per discussion on #16907 — it does not affect queue/Docker selection.

When the JobMonitor resubmitted failed Helix work items, it built the
JobCreationRequest using only the resolved QueueId from Job.DetailsAsync
(Docker tag and queue alias stripped), so a work item that originally ran
inside a Docker container was re-run on the bare host queue.

Reconstruct the original target queue from the `operatingSystem` job
property (which the Helix SDK stamps verbatim with $(HelixTargetQueue),
in `(alias)queueId@dockerTag` form) and parse it with the same logic the
fresh submission path uses (JobDefinition.ParseQueueId), setting QueueId,
DockerTag and QueueAlias consistently. Falls back to the resolved QueueId
with no Docker tag/alias when the property is absent or unparseable.

Fixes dotnet#16961

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 3, 2026 17:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a JobMonitor resubmission fidelity issue where resubmitted Helix work items could lose DockerTag/QueueAlias (causing reruns to execute on the bare host queue instead of the intended Docker-backed environment). It reconstructs the original target queue from the job’s operatingSystem property (stamped by the Helix SDK) so resubmissions match the fresh-submission path.

Changes:

  • Update HelixService.ResubmitWorkItemsAsync to parse the original target queue from the operatingSystem property and set QueueId, DockerTag, and QueueAlias on the resubmitted JobCreationRequest, with a safe fallback to the resolved QueueId when missing/unparseable.
  • Add unit tests covering alias+docker, docker-only, non-docker, and unparseable operatingSystem scenarios.
  • Extend existing resubmission metadata test assertions to validate DockerTag/QueueAlias default behavior when the property is absent.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/Microsoft.DotNet.Helix/JobMonitor/Services/HelixService.cs Reconstructs and applies QueueId/DockerTag/QueueAlias for resubmitted jobs by parsing the operatingSystem property (mirroring JobSender behavior), with fallback to prior behavior.
src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/HelixServiceTests.cs Adds/updates tests to ensure resubmission preserves Docker/alias info (and falls back correctly) based on the operatingSystem property.

…eueSpec

Extract the Docker tag / queue alias recovery into a single replaceable
method and link it to the tracking issue (dotnet#16964) so it can be
swapped for direct JobDetails.DockerTag/QueueAlias reads once the Helix
details API exposes them (dotnet-helix-service PR 61770).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@premun
premun merged commit 0b62d3d into dotnet:main Jun 4, 2026
10 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview6 milestone Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JobMonitor: Resubmitted work items lose DockerTag/QueueAlias (wrong execution environment)

3 participants