Conversation
It's not enabled by default, now it requires the --exporter-logs flag, otherwise it becomes too annoying, for example when doing a serial console session or other activities.
✅ Deploy Preview for jumpstarter-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
WalkthroughThe changes remove an asynchronous log streaming context from the CLI execution and introduce a new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI
participant Shell
participant LeaseClient
participant LogStream
User->>CLI: Run `shell` command (with/without --exporter-logs)
CLI->>Shell: Call shell(config, ..., exporter_logs)
alt exporter_logs enabled
Shell->>LeaseClient: Connect
LeaseClient->>LogStream: Open log stream
LogStream->>Shell: Stream logs
Shell->>Shell: Launch shell session
LogStream-->>LeaseClient: Close log stream
else exporter_logs disabled
Shell->>Shell: Launch shell session directly
end
Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/jumpstarter-cli/jumpstarter_cli/shell.py (1)
26-26: Add type annotation for the new parameter.The function signature should include a type annotation for the
exporter_logsparameter for better code clarity and IDE support.-def shell(config, command: tuple[str, ...], lease_name, selector, duration, exporter_logs): +def shell(config, command: tuple[str, ...], lease_name, selector, duration, exporter_logs: bool):
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/jumpstarter-cli/jumpstarter_cli/j.py(1 hunks)packages/jumpstarter-cli/jumpstarter_cli/shell.py(2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/jumpstarter-cli/jumpstarter_cli/shell.py (4)
packages/jumpstarter-cli-common/jumpstarter_cli_common/exceptions.py (1)
handle_exceptions_with_reauthentication(49-72)packages/jumpstarter-cli/jumpstarter_cli/login.py (1)
relogin_client(141-155)packages/jumpstarter/jumpstarter/config/client.py (1)
lease(118-126)packages/jumpstarter/jumpstarter/common/utils.py (1)
launch_shell(49-114)
⏰ 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). (7)
- GitHub Check: pytest-matrix (macos-15, 3.12)
- GitHub Check: pytest-matrix (ubuntu-24.04, 3.12)
- GitHub Check: pytest-matrix (macos-15, 3.11)
- GitHub Check: pytest-matrix (ubuntu-24.04, 3.13)
- GitHub Check: pytest-matrix (macos-15, 3.13)
- GitHub Check: pytest-matrix (ubuntu-24.04, 3.11)
- GitHub Check: e2e
🔇 Additional comments (2)
packages/jumpstarter-cli/jumpstarter_cli/shell.py (1)
23-23: LGTM: Well-documented CLI option added.The
--exporter-logsflag is properly implemented with appropriate help text.packages/jumpstarter-cli/jumpstarter_cli/j.py (1)
22-22: LGTM: Clean removal of unconditional log streaming.The removal of the
log_stream_asynccontext manager aligns perfectly with the PR objective of making log streaming conditional rather than always-on. This change, combined with the conditional implementation inshell.py, provides better user control over log output.
| if exporter_logs: | ||
| with lease.connect() as client: | ||
| with client.log_stream(): | ||
| exit_code = launch_shell( | ||
| path, | ||
| "remote", | ||
| config.drivers.allow, | ||
| config.drivers.unsafe, | ||
| command=command, | ||
| ) | ||
| else: | ||
| exit_code = launch_shell( | ||
| path, | ||
| "remote", | ||
| config.drivers.allow, | ||
| config.drivers.unsafe, | ||
| command=command, | ||
| ) |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Refactor to eliminate code duplication.
The conditional logic contains significant code duplication. The launch_shell call is identical in both branches, only the context differs.
- if exporter_logs:
- with lease.connect() as client:
- with client.log_stream():
- exit_code = launch_shell(
- path,
- "remote",
- config.drivers.allow,
- config.drivers.unsafe,
- command=command,
- )
- else:
- exit_code = launch_shell(
- path,
- "remote",
- config.drivers.allow,
- config.drivers.unsafe,
- command=command,
- )
+ def run_shell():
+ return launch_shell(
+ path,
+ "remote",
+ config.drivers.allow,
+ config.drivers.unsafe,
+ command=command,
+ )
+
+ if exporter_logs:
+ with lease.connect() as client:
+ with client.log_stream():
+ exit_code = run_shell()
+ else:
+ exit_code = run_shell()📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if exporter_logs: | |
| with lease.connect() as client: | |
| with client.log_stream(): | |
| exit_code = launch_shell( | |
| path, | |
| "remote", | |
| config.drivers.allow, | |
| config.drivers.unsafe, | |
| command=command, | |
| ) | |
| else: | |
| exit_code = launch_shell( | |
| path, | |
| "remote", | |
| config.drivers.allow, | |
| config.drivers.unsafe, | |
| command=command, | |
| ) | |
| def run_shell(): | |
| return launch_shell( | |
| path, | |
| "remote", | |
| config.drivers.allow, | |
| config.drivers.unsafe, | |
| command=command, | |
| ) | |
| if exporter_logs: | |
| with lease.connect() as client: | |
| with client.log_stream(): | |
| exit_code = run_shell() | |
| else: | |
| exit_code = run_shell() |
🤖 Prompt for AI Agents
In packages/jumpstarter-cli/jumpstarter_cli/shell.py between lines 46 and 63,
the launch_shell function is called with the same arguments in both branches of
the if-else, causing code duplication. Refactor by moving the launch_shell call
outside the if-else block and only conditionally wrap it with the
lease.connect() and client.log_stream() context managers when exporter_logs is
true, to eliminate the duplicated launch_shell call.
It's not enabled by default, now it requires the --exporter-logs flag, otherwise it becomes too annoying, for example when doing a serial console session or other activities.
Fixes-Issue: #554
Summary by CodeRabbit
New Features
Bug Fixes