Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

wait spinner: throttle#760

Merged
mangelajo merged 2 commits intojumpstarter-dev:mainfrom
mangelajo:throttle-spinner-losg
Dec 2, 2025
Merged

wait spinner: throttle#760
mangelajo merged 2 commits intojumpstarter-dev:mainfrom
mangelajo:throttle-spinner-losg

Conversation

@mangelajo
Copy link
Copy Markdown
Member

@mangelajo mangelajo commented Dec 1, 2025

Without this throttling waiting logs can get way too long.

Summary by CodeRabbit

  • Bug Fixes

    • Improved lease acquisition status reporting: critical success messages are always shown while routine status updates are throttled to reduce log spam; timing display preserved.
  • Tests

    • Added tests covering throttled logging behavior and spinner/console status update paths.

✏️ Tip: You can customize this high-level summary in your review settings.

@netlify
Copy link
Copy Markdown

netlify bot commented Dec 1, 2025

Deploy Preview for jumpstarter-docs ready!

Name Link
🔨 Latest commit 0799245
🔍 Latest deploy log https://app.netlify.com/projects/jumpstarter-docs/deploys/692ea50abab80000088116c9
😎 Deploy Preview https://deploy-preview-760--jumpstarter-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Dec 1, 2025

Walkthrough

Adds throttled, non-spinner logging to LeaseAcquisitionSpinner so status messages are logged at most every 5 minutes when no spinner is present; adds a force flag to update_status to bypass throttling and ensures spinner success messages are forced to display.

Changes

Cohort / File(s) Summary
Spinner logic & throttled logging
packages/jumpstarter/jumpstarter/client/lease.py
Added last-log timestamp and 5-minute throttle interval to LeaseAcquisitionSpinner; update_status(self, message: str, force: bool = False) now uses spinner when available, otherwise logs subject to throttle unless force=True. Preserves elapsed-time display.
Unit tests for throttling
packages/jumpstarter/jumpstarter/client/lease_test.py
Added tests covering first/forced updates, throttled suppression within interval, interval-based logging after throttle period, multiple updates, and behavior when a console/spinner is available.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review lease.py for correct time-tracking, throttle interval handling, and proper use of force to bypass throttling.
  • Verify tests in lease_test.py thoroughly exercise edge cases (forced updates, interval boundaries, and spinner-present path).

Possibly related PRs

  • jumpstarter-dev/jumpstarter#688 — Earlier changes to LeaseAcquisitionSpinner and non-spinner logging behavior that this PR extends with throttling and a force flag.

Suggested reviewers

  • kirkbrauer
  • NickCao

Poem

🐇 I hopped to log, then paused my paw,
Five minutes of quiet keeps noise from the maw,
But whisper "force" and I'll shout with delight,
Spinner or silence — I'll get it just right,
Hooray for tidy logs into the night! 🎉

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'wait spinner: throttle' directly and concisely describes the main change: adding throttling functionality to the wait spinner logging system.
Docstring Coverage ✅ Passed Docstring coverage is 84.62% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@mangelajo mangelajo enabled auto-merge December 2, 2025 08:36
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
packages/jumpstarter/jumpstarter/client/lease.py (1)

364-389: Throttling logic is correct and well-implemented.

The throttling implementation properly handles all scenarios:

  • Forces logs when force=True (e.g., success messages)
  • Always logs the first update (_last_log_time is None)
  • Throttles subsequent updates to once per 5-minute interval
  • Only applies throttling when no spinner is available

The logic is sound and achieves the PR objective of preventing excessively long logs during lease acquisition.

Optional: Extract elapsed time calculation to reduce duplication.

The elapsed time calculation appears twice (lines 372-373 and 386-387). Consider extracting to a helper method:

def _get_elapsed_str(self) -> str:
    """Get formatted elapsed time string without microseconds."""
    elapsed = datetime.now() - self.start_time
    return str(elapsed).split(".")[0]

Then use it in both paths:

 if self.spinner and self._should_show_spinner:
     self._current_message = f"[blue]{message}[/blue]"
-    elapsed = datetime.now() - self.start_time
-    elapsed_str = str(elapsed).split(".")[0]
+    elapsed_str = self._get_elapsed_str()
     self.spinner.update(f"{self._current_message} [dim]({elapsed_str})[/dim]")
 else:
     # ...
     if should_log:
-        elapsed = now - self.start_time
-        elapsed_str = str(elapsed).split(".")[0]
+        elapsed_str = self._get_elapsed_str()
         logger.info(f"{message} ({elapsed_str})")
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e4127cb and 0799245.

📒 Files selected for processing (1)
  • packages/jumpstarter/jumpstarter/client/lease.py (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (.cursor/rules/project-structure.mdc)

Ruff should be used for code formatting and linting, excluding jumpstarter-protocol package

Files:

  • packages/jumpstarter/jumpstarter/client/lease.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
  • GitHub Check: Redirect rules - jumpstarter-docs
  • GitHub Check: Header rules - jumpstarter-docs
  • GitHub Check: Pages changed - jumpstarter-docs
  • GitHub Check: build
  • GitHub Check: pytest-matrix (ubuntu-24.04, 3.11)
  • GitHub Check: pytest-matrix (ubuntu-24.04, 3.12)
  • GitHub Check: pytest-matrix (ubuntu-24.04, 3.13)
  • GitHub Check: pytest-matrix (macos-15, 3.12)
  • GitHub Check: pytest-matrix (macos-15, 3.13)
  • GitHub Check: e2e
🔇 Additional comments (2)
packages/jumpstarter/jumpstarter/client/lease.py (2)

162-162: LGTM! Success message correctly bypasses throttling.

Forcing the success message ensures users always see when lease acquisition completes, which is good UX for an important state transition.


335-336: LGTM! Throttle state properly initialized.

The throttle tracking fields are correctly initialized with None for the first log to pass through and a reasonable 5-minute interval for long-running acquisitions.

@mangelajo mangelajo merged commit 312a389 into jumpstarter-dev:main Dec 2, 2025
18 checks passed
@jumpstarter-backport-bot
Copy link
Copy Markdown

Backport failed for release-0.7, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release-0.7
git worktree add -d .worktree/backport-760-to-release-0.7 origin/release-0.7
cd .worktree/backport-760-to-release-0.7
git switch --create backport-760-to-release-0.7
git cherry-pick -x e4127cbb850287bcc61e4b3bb99bfbab54c95a50

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants