Skip to content

fix(packaging): Retry the macOS volume detach by device, not by a stale path (#2728) - #2729

Merged
zackees merged 2 commits into
masterfrom
infra/2728-dmg-detach-retry
Oct 28, 2026
Merged

zackees merged 2 commits into
masterfrom
infra/2728-dmg-detach-retry

Conversation

@zackees

@zackees zackees commented Oct 28, 2026

Copy link
Copy Markdown
Member

Refs #2728 (this clears the release-blocking abort but is not the whole issue's cause: Resource busy itself is a runner condition).

RED / GREEN

  • RED b00b1dd7a — ci/test_macos_diskimage_retry.py fails on master: create_diskimage has no detach helper, so safe_hdiutil detach /Volumes/<name> retries a path that the first failed attempt destroys.
  • GREEN 483f04069 — safe_detach_volume in .github/scripts/utils.zsh/create_diskimage; the test passes.

Why

release-rust.yaml -f verify_only=true on master fc0352611 (run 40627344990) lost Build macos arm64 🧱 → Package OBS-Studio-Rust 📀 (job 122615438598) after compilation, codesign and the .app bundle had all succeeded:

03:46:49.430  hdiutil: couldn't eject "disk33" - Resource busy
03:46:51.737  hdiutil: detach failed - No such file or directory   (attempts #2-#5)
03:47:52.337  ##[error] Unable to run 'hdiutil detach /Volumes/...'. Aborting
03:47:52.794  ##[error] Disk image creation failed.

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>:

  1. returns success when the mountpoint is already gone;
  2. resolves the device once (hdiutil info) and retries that, since it outlives the mountpoint;
  3. keeps the existing backoff and the XProtect kill;
  4. makes one hdiutil detach -force the last resort before aborting.

safe_hdiutil create/attach are untouched, and the ERR trap 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 info device retry, -force last resort).
  • zsh -n .github/scripts/utils.zsh/create_diskimage with zsh 5.9.1: parses.
  • Behavioural run of the extracted helper under zsh 5.9.1 with a stubbed hdiutil that fails Resource busy once and removes the mountpoint: the old shape failed all five attempts (rc=2); the new helper returns 0 on the second iteration (hdiutil detach /dev/disk33s1 after hdiutil info). Already-detached case: rc=0 with no hdiutil detach call.
  • Not verified: a real macOS DMG package. This host has no macOS; the release lane is the only oracle, so please let release-rust.yaml confirm it.

No docs/features.md line: packaging internals, no user-visible behaviour change.

…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 zackees left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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 -force fallback, 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;
  • _backoff is 5 entries for a {1..5} loop, and zsh's 1-based indexing makes ${_backoff[${i}]} correct;
  • the ERR trap's ... || true prevents the trap re-entering safe_detach_volume when the helper itself returns 2;
  • only the detach site changed — create/attach/convert still go through the generic safe_hdiutil retry, 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.

@zackees

zackees commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

Handed off to the coordinator — PR CI is green (Fast Gate ⚡, Format 🔍 / checks, CI Mode 🛂, Validate Data), ./lint ok locally (60.6s), and the PR is queued (position 2, AWAITING_CHECKS).

Note for the coordinator: my local rebase onto 6e3e66900 could not be pushed because the branch is protected against force pushes, and it is not needed — the queue entry is the pre-rebase head 483f04069, which the queue merges onto current master itself.

Merged via the queue into master with commit 25fc4bc Oct 28, 2026
32 checks passed
@zackees
zackees deleted the infra/2728-dmg-detach-retry branch October 28, 2026 04:18
@zackees

zackees commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

Post-merge evidence from the release lane, since a utils.zsh packaging helper has no PR-CI compile path: run 40631862829 (verify_only=true, head 25fc4bc6e, i.e. this merge) — Build macos arm64 🧱 success, created: …obs-studio-33.0.0-beta6-25fc4bc6e-macos-apple.dmg, packaged identity verified.

That is the job that aborted at Package OBS-Studio-Rust 📀 in run 40627344990 (hdiutil detach retrying a mountpoint that the first attempt had unmounted), so the detach rewrite is confirmed in the environment it was written for. Detail for the record: the detach succeeded on the first attempt, so the new retry branch was not exercised on the runner — the evidence is "unblocked and no regression", not "retry path demonstrated".

Both packaged-startup jobs then passed: Native macOS arm64 DMG startup 🧪 (success) and x86_64 (success).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant