Skip to content

Retry instance directory deletion on ENOTEMPTY#191

Merged
sjmiller609 merged 1 commit intomainfrom
codex/delete-instance-removeall-retry
Apr 8, 2026
Merged

Retry instance directory deletion on ENOTEMPTY#191
sjmiller609 merged 1 commit intomainfrom
codex/delete-instance-removeall-retry

Conversation

@sjmiller609
Copy link
Copy Markdown
Collaborator

@sjmiller609 sjmiller609 commented Apr 8, 2026

Summary

  • retry instance directory deletion when os.RemoveAll loses a race with concurrent writers and returns ENOTEMPTY
  • use exponential backoff starting at 10ms and capping at 100ms for up to 5 retries
  • add unit coverage for retry success and retry exhaustion

Testing

  • go test ./lib/instances -run 'TestRemoveAllWithRetry|TestMetadataPersistence' (fails in this checkout because embedded binaries lib/system/guest_agent/guest-agent and lib/hypervisor/vz/vz-shim/vz-shim are missing)

Note

Medium Risk
Touches instance deletion cleanup by adding retry/backoff around os.RemoveAll, which could impact teardown timing and error handling if the retry logic misbehaves. Change is localized and guarded to only retry ENOTEMPTY with a small capped backoff.

Overview
Improves instance teardown robustness by retrying instance directory removal when os.RemoveAll fails with ENOTEMPTY, using an exponential backoff (10ms doubling, capped at 100ms) for up to 5 retries via removeAllWithRetry.

Adds unit tests covering both the successful retry path and the max-retry exhaustion behavior, including verification of the backoff schedule.

Reviewed by Cursor Bugbot for commit 4a33f36. Bugbot is set up for automated code reviews on this repo. Configure here.

@sjmiller609 sjmiller609 requested a review from hiroTamada April 8, 2026 20:54
@sjmiller609 sjmiller609 marked this pull request as ready for review April 8, 2026 20:54
@sjmiller609 sjmiller609 merged commit 0c34825 into main Apr 8, 2026
6 checks passed
@sjmiller609 sjmiller609 deleted the codex/delete-instance-removeall-retry branch April 8, 2026 20:57
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.

2 participants