Skip to content

engine: retry a volume mount while the device is not yet openable - #404

Merged
CMGS merged 2 commits into
mainfrom
fix/volume-mount-device-ready
Oct 29, 2026
Merged

CMGS merged 2 commits into
mainfrom
fix/volume-mount-device-ready

Conversation

@CMGS

@CMGS CMGS commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #400.

Cause (cocoon-test2, 620 claim-time mounts across cocoon v0.7.2–v0.7.4 and two rt:24.04 digests): after a hot attach the guest creates /sys/block/vdX and the /dev/vdX node before the kernel can open the disk. waitForVolumeDevice returns on the node, and mount then fails with /dev/vdc is not a valid block device (exit 32). All three failures came on settled VMs where the device appeared within 13–14 ms of the attach.

Change: mountDevice retries the mount only on that error, on the existing 10 ms poll interval, until the volume setup timeout. Any other mount failure (wrong filesystem, busy mount point, permission) still returns on the first attempt, as TestMountVolumeStopsAtFailedStage checks.

Cost: none on the normal path (one mount exec as before); a not-ready device costs one extra exec per 10 ms until it opens.

Test: TestMountVolumeRetriesUntilTheDeviceOpens (fake silkd returns the error twice, the third mount succeeds); it fails when the retry is removed.

Gates: golangci-lint 0 issues. (sandboxd, linux and darwin), fmt clean, go test -race ./engine/ ./pool/. Not yet run on hardware: the race is about 1 in 200 mounts, so a hardware check needs a long claim loop; I can run one on cocoon-test2 before merge if you want.

CMGS added 2 commits October 29, 2026 18:21
The guest publishes /sys/block and the /dev node before the kernel can open a hot-plugged disk, so mount occasionally failed with "not a valid block device" (3 of 620 mounts on cocoon-test2). Retry only that error on the existing poll interval within the setup timeout; any other mount failure still returns at once.
A retry that ran into the setup deadline returned the last mount error, so the live volume API answered 500 instead of 504. Wrap ctx.Err() whenever the context has ended, both after a failed attempt and while waiting, keeping the last mount error in the message.
@CMGS CMGS closed this Oct 29, 2026
@CMGS
CMGS deleted the fix/volume-mount-device-ready branch October 29, 2026 12:58
@CMGS
CMGS restored the fix/volume-mount-device-ready branch October 29, 2026 12:58
@CMGS CMGS reopened this Oct 29, 2026
@CMGS
CMGS merged commit 92585ed into main Oct 29, 2026
2 checks passed
@CMGS
CMGS deleted the fix/volume-mount-device-ready branch October 29, 2026 13:02
CMGS added a commit that referenced this pull request Oct 29, 2026
WithVolumesAttachOnly and mount=False no longer validate locally (sandboxd answers 400), Volume carries attach_only, a mount reporting "not a valid block device" is retried within the setup budget (#404), and the README names runtime volume registration (#382).
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.

Claim-time volume mount occasionally sees the device before it is a valid block device

1 participant