Skip to content

fix(ca_utils): harden instance delay and lock error handling - #154

Merged
mkoura merged 1 commit into
masterfrom
fix/instance-delay-hardening
Aug 13, 2026
Merged

fix(ca_utils): harden instance delay and lock error handling#154
mkoura merged 1 commit into
masterfrom
fix/instance-delay-hardening

Conversation

@mkoura

@mkoura mkoura commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

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

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.Timeout and OSError handling 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.

Comment thread src/cardonnay/ca_utils.py
Comment thread src/cardonnay/cli_create.py
@mkoura
mkoura merged commit ebe90f7 into master Aug 13, 2026
5 checks passed
@mkoura
mkoura deleted the fix/instance-delay-hardening branch August 13, 2026 09:58
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