Skip to content

ci: let the deadline of the workspace image restore stop the Linux and macOS mounts - #346256

Merged
Ladislau Szomoru (lszomoru) merged 1 commit into
mainfrom
lszomoru/agents/workspace-image-restore-mounts
Nov 5, 2026
Merged

Ladislau Szomoru (lszomoru) merged 1 commit into
mainfrom
lszomoru/agents/workspace-image-restore-mounts

Conversation

@lszomoru

Copy link
Copy Markdown
Member

Follow-up to #346254, for its review comment, which came in after it merged.

The mount commands of image.ts restore on Linux (sudo blockdev and sudo mount) and macOS (diskutil image attach) ran synchronously, which held back the timer of the deadline that #346254 added: a stalled mount could still reach the timeout of the step with the image half attached, and a slow mount could report the image after the deadline.

What changed

  • These commands now run asynchronously (runUntilDeadline), and the deadline stops them. As on Windows, the restore waits for the process to exit before it cleans up.
  • When the deadline stops them after the mount completed, the restore unmounts the image (only when a volume is mounted at the folder), and on Linux detaches the loop device, as after any other error.
  • The restore checks the deadline once more before it reports the image, as synchronous work can hold back its timer; a late image is unmounted like an image with the wrong commit.
  • The Windows attach uses the same helper to wait for the exit of PowerShell; its behavior doesn't change.

No job restores an image yet, and the commands that build the images are unchanged.

How to test

Validation of this change:

  • ./node_modules/.bin/tsc --noEmit --strict --module nodenext --moduleResolution nodenext --target es2024 --lib es2024,dom --types node --skipLibCheck --erasableSyntaxOnly --noUnusedLocals --noUnusedParameters .github/workflows/workspace_image/image.ts: passed
  • ./node_modules/.bin/eslint .github/workflows/workspace_image/image.ts: passed
  • cd build && node --test lib/test/detectMissingCaches.test.ts lib/test/detectChanges.test.ts lib/test/workspaceImage.test.ts lib/test/agentHostTestSelection.test.ts: 34 passed
  • image.ts restore on macOS against a local mock of the API and of an artifact, with a fake diskutil first on the PATH: an attach that stalls for 30 s with a 3 s deadline now stops after 3.2 s with used=false and an empty workspace (before, it blocked for 30 s); an attach that completes without a valid image unmounts it and reports used=false.
  • Not run: the Linux mount, which needs a runner with sudo.

…d macOS mounts

The mount commands of Linux (sudo blockdev and sudo mount) and macOS
(diskutil image attach) ran synchronously, which held back the timer of
the deadline: a stalled mount could still reach the timeout of the step
with the image half attached, and a slow mount could report the image
after the deadline. They now run asynchronously, and the deadline stops
them; a mount that completed before they stopped is unmounted, and the
Linux loop device detached, as after any other error. The restore also
checks the deadline once more before it reports the image, as
synchronous work can hold back its timer.

Co-authored-by: Alex Dima <alexdima@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 5, 2026 14:13

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.

🟡 Changes recommended

Synchronous Git configuration can overrun the deadline and still report success while leaving the late image mounted.

1 open issue
What changed in this PR

This follow-up extends workspace-image restore deadline handling to Linux and macOS, addressing synchronous mount commands that could block timeout handling.

Changes:

  • Runs Linux and macOS mount commands asynchronously and waits for process exit before cleanup.
  • Cleans up mounts after failures and checks the deadline before accepting a restored image.
  • Shares the process-exit helper with Windows without changing its attach behavior.
File Description
.github/​workflows/​workspace_image/​image.ts Adds deadline-aware mount commands, failure cleanup, and a final restore deadline check.

Review effort: Balanced

if (!fs.existsSync(path.join(ws, '.git'))) {
throw new Error('The image holds no .git');
}
checkDeadline();
@lszomoru
Ladislau Szomoru (lszomoru) merged commit 4f9a2bc into main Nov 5, 2026
108 of 110 checks passed
@lszomoru
Ladislau Szomoru (lszomoru) deleted the lszomoru/agents/workspace-image-restore-mounts branch November 5, 2026 15:17
@vs-code-engineering vs-code-engineering Bot added this to the 1.146.0 milestone Nov 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.

4 participants