Repository navigation
fix(packaging): Retry the macOS volume detach by device, not by a stale path (#2728) - #2729
Conversation
…tpoint (RED, #2728) The test fails on master: create_diskimage has no dedicated detach helper, so it retries 'hdiutil detach /Volumes/<name>' five times and aborts once the first attempt is Resource busy and the mountpoint disappears.
…le path (GREEN, #2728) `create_diskimage` detached the staged volume with `safe_hdiutil detach /Volumes/<name>`, which retries the same argv five times. When the first attempt returns `Resource busy` the volume is half-ejected and the mountpoint is gone, so every later attempt fails while resolving the path (`No such file or directory`) - the state that was being asked for - and packaging aborts with "Disk image creation failed". Master run 40627344990 (`Build macos arm64`, job 122615438598) lost a release-gate run this way. Detach now goes through `safe_detach_volume`: - an already-unmounted volume is success, not an error; - the device node is resolved once with `hdiutil info` and retried, so it survives the mountpoint disappearing; - the backoff and the XProtect kill stay; - one `hdiutil detach -force` is the last resort before aborting. Verified locally with zsh 5.9.1: `zsh -n` parses the file, and a stubbed `hdiutil` that fails busy once and removes the mountpoint now returns 0 after the retry, where the old loop failed all five attempts on the missing path.
zackees
left a comment
There was a problem hiding this comment.
Reviewed the diff on 483f040 and ran the new pin locally (uv run --no-project --script ci/test_macos_diskimage_retry.py → 5 tests OK).
Correct. The diagnosis matches run 40627344990: safe_hdiutil detach /Volumes/<name> retried an argv that stops resolving the moment the first attempt leaves the volume half-ejected, so the second attempt fails on path resolution (No such file or directory) rather than on Resource busy and the release aborts. Retrying the device node is the right fix, and "mountpoint gone ⇒ already detached ⇒ success" is the state the release wanted.
Checks I verified:
- the mountpoint-gone test comes before the detach attempt and before the
-forcefallback, so a volume that disappears between attempts exits 0 on the next iteration; - the device is resolved once and cached (
if [[ -z ${device} ]]), so a resolution failure falls back to the mountpoint instead of blanking it; _backoffis 5 entries for a{1..5}loop, and zsh's 1-based indexing makes${_backoff[${i}]}correct;- the
ERRtrap's... || trueprevents the trap re-enteringsafe_detach_volumewhen the helper itself returns 2; - only the detach site changed —
create/attach/convertstill go through the genericsafe_hdiutilretry, which is what the test pins.
Non-blocking nit, no change requested: the awk matches the mountpoint with index($0, mp), so a volume whose name is a prefix of the mount point (/Volumes/OBS vs /Volumes/OBS-Studio-Rust) would match the wrong entry. $NF == mp is exact for the hdiutil info layout, but it breaks for mountpoints containing spaces, so the current form is a defensible trade — worth a comment either way.
No docs/features.md line: this is release packaging, not user-visible behaviour. No Tier 2/differential coverage applies to a utils.zsh helper that only runs on a macOS release runner; the source-shape pin plus the release gate are the available evidence.
|
Handed off to the coordinator — PR CI is green ( Note for the coordinator: my local rebase onto |
|
Post-merge evidence from the release lane, since a That is the job that aborted at Both packaged-startup jobs then passed: |
Refs #2728 (this clears the release-blocking abort but is not the whole issue's cause:
Resource busyitself is a runner condition).RED / GREEN
b00b1dd7a—ci/test_macos_diskimage_retry.pyfails on master:create_diskimagehas no detach helper, sosafe_hdiutil detach /Volumes/<name>retries a path that the first failed attempt destroys.483f04069—safe_detach_volumein.github/scripts/utils.zsh/create_diskimage; the test passes.Why
release-rust.yaml -f verify_only=trueon masterfc0352611(run40627344990) lostBuild macos arm64 🧱→Package OBS-Studio-Rust 📀(job122615438598) after compilation, codesign and the.appbundle had all succeeded:Attempt #1 fails on a busy volume; the half-ejected volume then removes the mountpoint, so attempts #2-#5 fail while resolving the path — which is the desired end state, reported as fatal. The same job passed on
b926b01c4, so this is intermittent and the retry only ever "works" when the first attempt does.Change
safe_detach_volume <mount point>:hdiutil info) and retries that, since it outlives the mountpoint;XProtectkill;hdiutil detach -forcethe last resort before aborting.safe_hdiutil create/attachare untouched, and theERRtrap now uses the new helper so the cleanup path benefits from it too.Verification
ci/test_macos_diskimage_retry.py— RED on master, green here (source-shape pin: detach site uses the helper, already-unmounted is success,hdiutil infodevice retry,-forcelast resort).zsh -n .github/scripts/utils.zsh/create_diskimagewith zsh 5.9.1: parses.hdiutilthat failsResource busyonce and removes the mountpoint: the old shape failed all five attempts (rc=2); the new helper returns0on the second iteration (hdiutil detach /dev/disk33s1afterhdiutil info). Already-detached case:rc=0with nohdiutil detachcall.release-rust.yamlconfirm it.No
docs/features.mdline: packaging internals, no user-visible behaviour change.