Skip to content

fix: set lease_ended on monitor cancellation when end time has passed#599

Draft
raballew wants to merge 2 commits intojumpstarter-dev:mainfrom
raballew:051-fix-lease-expiry
Draft

fix: set lease_ended on monitor cancellation when end time has passed#599
raballew wants to merge 2 commits intojumpstarter-dev:mainfrom
raballew:051-fix-lease-expiry

Conversation

@raballew
Copy link
Copy Markdown
Member

Summary

  • When a lease expires during beforeLease hook execution, the lease monitor task gets cancelled before detecting the expiry, causing the client to show "Connection to exporter lost" instead of exiting gracefully
  • Add a finally block to _monitor that checks whether the cached end time has passed when cancelled, and calls _notify_lease_ending to set lease_ended=True

Closes #235

Test plan

  • Verify _monitor sets lease_ended when cancelled after end time passes
  • Verify existing lease expiry tests still pass
  • Run make pkg-test-jumpstarter

🤖 Generated with Claude Code

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 17, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ad091d10-cb9b-4c2d-91f1-aab2509a231e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

last_known_end_time,
try:
while True:
try:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We could consider extractring this block to another private method to improve readability

raballew and others added 2 commits April 17, 2026 12:40
…jumpstarter-dev#235)

When a lease expires during beforeLease hook execution, the lease
monitor task gets cancelled before it can detect the expiry and set
lease_ended. This causes the client to show "Connection to exporter
lost" instead of exiting gracefully.

Add a finally block to the _monitor function that checks whether the
cached end time has passed when the task is cancelled. If so, it calls
_notify_lease_ending to set lease_ended=True, allowing the existing
BaseExceptionGroup handler in _shell_with_signal_handling to recognize
the lease expiry and exit with code 0.

Generated-By: Forge/20260416_202054_681470_f3b15353_i235
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The ty type checker cannot narrow pytest.raises(BaseExceptionGroup)
value to BaseExceptionGroup, so .exceptions is unresolved.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@raballew raballew force-pushed the 051-fix-lease-expiry branch from 57132f8 to 9ff38df Compare April 17, 2026 10:46
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.

hooks enabled: lease with timeout at the boundary of beforeLease hook - Error: Connection to exporter lost

2 participants