Add properties to SSHWrapperClient#750
Conversation
Add command, identity, and username as class properties for SSHWrapperClient. Signed-off-by: Albert Esteve <aesteve@redhat.com>
Signed-off-by: Albert Esteve <aesteve@redhat.com>
✅ Deploy Preview for jumpstarter-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
WalkthroughThe SSHWrapperClient is refactored to expose Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
packages/jumpstarter-driver-ssh/jumpstarter_driver_ssh/client.py (1)
197-223: Minor edge cases and small duplication in SSH arg buildingThe overall behavior of
_build_ssh_command_args—deriving fromself.command, adding-iand-p, and injecting-l default_usernameonly when no-lis present in SSH options—looks correct and satisfies the existing tests, including the “command-lvs SSH-l” scenarios.Two low‑priority observations:
argsare parsed twice via_separate_ssh_options_and_command_args(here and again in_run_ssh_local), which also doubles the debug logging; you could optionally parse once in_run_ssh_localand passssh_options/command_argsinto this helper.- If the user passes a bare
-lwith no following username,has_user_flagstays false, so the final command will contain both the raw-lfromssh_optionsand the injected-l default_username, which might be surprising; you may want to treat a lone-las “user already managing login” or raise early.Both are minor and can be deferred if current behavior is acceptable.
packages/jumpstarter-driver-ssh/jumpstarter_driver_ssh/driver_test.py (1)
697-709: Property test covers new client surface well
test_ssh_client_propertiesis a good, focused check that the client’susername,identity, andcommandproperties reflect the driver configuration over the realserve(...)pathway, matching the refactor intent. If you ever extend identity sourcing further (e.g., more complex file‑based flows), you could add a similar test for thessh_identity_filecase, but this is already solid as‑is.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/jumpstarter-driver-ssh/jumpstarter_driver_ssh/client.py(5 hunks)packages/jumpstarter-driver-ssh/jumpstarter_driver_ssh/driver_test.py(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: mangelajo
Repo: jumpstarter-dev/jumpstarter PR: 647
File: packages/jumpstarter-driver-ssh/jumpstarter_driver_ssh/client.py:0-0
Timestamp: 2025-09-25T05:52:27.157Z
Learning: In the SSHWrapper driver's client.py, hostname replacement should only occur for "userhostname" format arguments that get preprocessed into "-l user hostname". Regular hostname arguments (like "device" in SSH commands) should be passed through unchanged to allow the wrapper to handle connections internally.
📚 Learning: 2025-09-25T05:52:27.157Z
Learnt from: mangelajo
Repo: jumpstarter-dev/jumpstarter PR: 647
File: packages/jumpstarter-driver-ssh/jumpstarter_driver_ssh/client.py:0-0
Timestamp: 2025-09-25T05:52:27.157Z
Learning: In the SSHWrapper driver's client.py, hostname replacement should only occur for "userhostname" format arguments that get preprocessed into "-l user hostname". Regular hostname arguments (like "device" in SSH commands) should be passed through unchanged to allow the wrapper to handle connections internally.
Applied to files:
packages/jumpstarter-driver-ssh/jumpstarter_driver_ssh/driver_test.pypackages/jumpstarter-driver-ssh/jumpstarter_driver_ssh/client.py
🧬 Code graph analysis (2)
packages/jumpstarter-driver-ssh/jumpstarter_driver_ssh/driver_test.py (3)
packages/jumpstarter-driver-ssh/jumpstarter_driver_ssh/driver.py (2)
SSHWrapper(9-50)client(28-29)packages/jumpstarter-driver-network/jumpstarter_driver_network/driver.py (1)
TcpNetwork(88-121)packages/jumpstarter-driver-ssh/jumpstarter_driver_ssh/client.py (3)
username(117-119)identity(103-114)command(98-100)
packages/jumpstarter-driver-ssh/jumpstarter_driver_ssh/client.py (1)
packages/jumpstarter/jumpstarter/client/base.py (1)
call(42-52)
⏰ 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). (11)
- GitHub Check: build
- 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.12)
- GitHub Check: pytest-matrix (macos-15, 3.12)
- GitHub Check: pytest-matrix (ubuntu-24.04, 3.11)
- GitHub Check: Redirect rules - jumpstarter-docs
- GitHub Check: e2e
- GitHub Check: Header rules - jumpstarter-docs
- GitHub Check: Pages changed - jumpstarter-docs
🔇 Additional comments (3)
packages/jumpstarter-driver-ssh/jumpstarter_driver_ssh/client.py (3)
97-120: Public SSH client properties wired correctly
command,identity, andusernameare clean property wrappers over the corresponding driver exports and match the new test expectations. This also makes the client API easier to use without changing behavior.
121-151: Refactored run() path keeps hostname vs command separation intactDelegating both direct and port‑forward flows to
_run_ssh_local(host, port, options, args)keeps all SSH construction in one place and still appends the TCP host separately fromargs, so command arguments like"hostname"remain untouched and are not misinterpreted as SSH hostnames. This aligns with the previous requirement that only preprocessed-l user hostnametriplets affect the SSH host, while regular command hostnames are preserved.Based on learnings
152-196: Identity temp‑file handling is robustUsing
self.identityto derive key material, writing it to aNamedTemporaryFilewith0600permissions, and always cleaning up in thefinallyblock (including best‑effort cleanup on creation failure) gives correct and predictable lifecycle behavior for the transient identity file. This matches and is well‑covered by the existing temp‑file creation/cleanup tests.
|
Backport failed for Please cherry-pick the changes locally and resolve any conflicts. git fetch origin release-0.7
git worktree add -d .worktree/backport-750-to-release-0.7 origin/release-0.7
cd .worktree/backport-750-to-release-0.7
git switch --create backport-750-to-release-0.7
git cherry-pick -x 7427850d033913410d4b125bc6b97527f13243d9 d946560313a4cc720dd79fd0c47ae3acf800b3dc |
|
Successfully created backport PR for |
Add
command,identity, andusernameas class properties for SSHWrapperClient.Summary by CodeRabbit
New Features
Refactor
Tests
✏️ Tip: You can customize this high-level summary in your review settings.