fix(ca_utils): harden instance delay and lock error handling - #154
Merged
Conversation
Lock timeouts and filesystem errors during instance reservation surfaced as raw tracebacks; odd directory or delay-file names could crash parsing or alias to a wrong instance number. - catch filelock.Timeout and OSError in delay/undelay/create paths, log actionable message, return failure instead of traceback - require ASCII digits when parsing instance numbers from state-cluster dirs and delay files (isdigit() passes for Unicode digits that int() rejects or maps to a different instance) - re-touch delay files with future mtime (wall clock stepped back) so the delay window stays bounded; fail closed on touch errors - treat undelay as best-effort: warn instead of error, stale delay expires within DELAY_VALID_SEC on its own - document False-return contracts and DELAY_LOCK precondition
There was a problem hiding this comment.
Pull request overview
This PR hardens testnet instance reservation/delay handling by improving lock/filesystem error paths and making instance parsing more robust against unexpected directory or delay-file names.
Changes:
- Wrap instance reservation/delay operations with
filelock.TimeoutandOSErrorhandling to avoid raw tracebacks and return clean failures. - Require ASCII digits when parsing instance numbers from state-cluster directories and delay status files, logging warnings for unexpected names.
- Add bounded delay semantics (
DELAY_VALID_SEC) and re-touch future-dated delay files to keep the delay window stable when clocks move backwards.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/cardonnay/cli_create.py | Reserves an instance under DELAY_LOCK, avoids tracebacks on lock/FS failures, and selects the first available non-delayed instance when instance_num < 0. |
| src/cardonnay/ca_utils.py | Adds DELAY_VALID_SEC, hardens parsing of instance IDs, and improves delay/undelay behavior and documentation around delay-file lifecycle. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lock timeouts and filesystem errors during instance reservation surfaced as raw tracebacks; odd directory or delay-file names could crash parsing or alias to a wrong instance number.