-
Notifications
You must be signed in to change notification settings - Fork 23
Add jumpstarter-driver-ssh-mount package for remote filesystem mounting #434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ambient-code
wants to merge
27
commits into
main
Choose a base branch
from
feature/322-filesystem-mount
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 24 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
4fd8e9f
Add mount/umount commands to SSH driver for sshfs-based filesystem mo…
76f605f
refactor: extract sshfs mount/umount into separate jumpstarter-driver…
0fb5928
fix: add ssh-mount to docs toctree and use SSH driver in example config
de41e1e
refactor: make SSHMount consume SSH driver for credentials and TCP ac…
f3433d5
Rename driver to 'mount', use --umount flag for cleaner CLI UX
e68d827
fix: address PR review feedback for ssh-mount driver
5861805
Fix lint C901 complexity in umount, add CLI dispatch tests
03a424f
Fix macOS test failures: use os.path.realpath for mount path assertions
774a844
Refactor mount to run sshfs in foreground with subshell
a8368f2
Fix lint errors and test failures in ssh-mount driver
ffe7596
Fix CI failures: unused variable lint error and test mock side_effects
a87523c
Add jumpstarter-driver-ssh-mount to UV workspace sources
2973cce
Address second review round: fix sshfs cleanup, deadlock, and macOS u…
2dba93c
Fix CI: remove unused sys import and fix generic failure test assertion
15f43a7
Fix extra_args -o prefix, remove dead port_forward param, add subshel…
65657a1
Fix SIGPIPE risk and ruff B904 lint error
aa602a7
Fix ruff B904: add 'from None' to raise in except clause
1c49d89
Address review feedback: fix fragile mountpoint extraction and misc i…
aeb2786
Remove hardcoded allow_other from default sshfs options
6948cd4
Update mount subshell prompt to match jmp shell style and fix macOS docs
143d419
Add fish shell support to mount subshell and improve -o/--extra-args …
991c40d
Address review feedback: type annotations, comma-separated allow_othe…
152240a
Fix test failures and lint errors in ssh-mount driver tests
5044c4f
Trim narrating comments and excessive docstrings per review feedback
ebd74fb
Address review feedback: fix option ordering, IPv6, process cleanup, …
8a508e9
fix: extract _terminate_proc helper to reduce C901 complexity and fix…
e8b3af2
Address review feedback: reduce verbosity, add tests, improve logging
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ../../../../../packages/jumpstarter-driver-ssh-mount/README.md | ||
|
mangelajo marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| __pycache__/ | ||
| .coverage | ||
| coverage.xml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| # SSHMount Driver | ||
|
|
||
| `jumpstarter-driver-ssh-mount` provides remote filesystem mounting via sshfs. It allows you to mount remote directories from a target device to your local machine using SSHFS (SSH Filesystem). | ||
|
|
||
| ## Installation | ||
|
|
||
| ```shell | ||
| pip3 install --extra-index-url https://pkg.jumpstarter.dev/simple/ jumpstarter-driver-ssh-mount | ||
| ``` | ||
|
|
||
| You also need `sshfs` installed on the client machine: | ||
|
|
||
| - **Fedora/RHEL**: `sudo dnf install fuse-sshfs` | ||
| - **Debian/Ubuntu**: `sudo apt-get install sshfs` | ||
| - **macOS**: Install macFUSE and SSHFS from https://macfuse.github.io/, please note that | ||
| it needs special handling to enable the macOS kernel extensions, read the install documentation | ||
| carefully. | ||
|
|
||
| ## Configuration | ||
|
|
||
| The SSHMount driver references an existing SSH driver to inherit credentials | ||
| (username, identity key) and TCP connectivity. No duplicate configuration is needed. | ||
|
|
||
| Example exporter configuration: | ||
|
|
||
| ```yaml | ||
| export: | ||
| ssh: | ||
| type: jumpstarter_driver_ssh.driver.SSHWrapper | ||
| config: | ||
| default_username: "root" | ||
| # ssh_identity_file: "/path/to/ssh/key" | ||
| children: | ||
| tcp: | ||
| type: jumpstarter_driver_network.driver.TcpNetwork | ||
| config: | ||
| host: "192.168.1.100" | ||
| port: 22 | ||
| mount: | ||
| type: jumpstarter_driver_ssh_mount.driver.SSHMount | ||
| children: | ||
| ssh: | ||
| ref: "ssh" | ||
| ``` | ||
|
|
||
| ## CLI Usage | ||
|
|
||
| Inside a `jmp shell` session: | ||
|
|
||
| ```shell | ||
| # Mount remote filesystem (spawns a subshell; type 'exit' to unmount) | ||
| j mount /local/mountpoint | ||
| j mount /local/mountpoint -r /remote/path | ||
| j mount /local/mountpoint --direct | ||
|
mangelajo marked this conversation as resolved.
|
||
|
|
||
| # Mount in foreground mode (blocks until Ctrl+C) | ||
| j mount /local/mountpoint --foreground | ||
|
|
||
| # Pass extra sshfs options (-o forwards each value as an sshfs -o flag) | ||
| j mount /local/mountpoint -o reconnect -o cache=yes | ||
|
|
||
| # Override default SSH options (e.g., enable host key checking) | ||
| j mount /local/mountpoint -o StrictHostKeyChecking=yes | ||
|
|
||
| # Allow other users to access the mount (requires user_allow_other in /etc/fuse.conf) | ||
| j mount /local/mountpoint -o allow_other | ||
|
|
||
| # Unmount an orphaned mount | ||
| j mount --umount /local/mountpoint | ||
| j mount --umount /local/mountpoint --lazy | ||
| ``` | ||
|
mangelajo marked this conversation as resolved.
raballew marked this conversation as resolved.
|
||
|
|
||
| By default, `j mount` runs sshfs in foreground mode and spawns a subshell | ||
| with a modified prompt. The mount stays active while the subshell is running. | ||
| When you type `exit` (or press Ctrl+D), sshfs is terminated and all resources | ||
| (port forwards, temporary identity files) are cleaned up automatically. | ||
|
|
||
| Use `--foreground` to skip the subshell and block directly on sshfs. Press | ||
| Ctrl+C to unmount. | ||
|
|
||
| The `--umount` flag is available as a fallback for mounts that were orphaned | ||
| (e.g., if the process was killed without cleanup). | ||
|
|
||
| ## API Reference | ||
|
|
||
| ### SSHMountClient | ||
|
|
||
| - `mount(mountpoint, *, remote_path="/", direct=False, foreground=False, extra_args=None)` - Mount remote filesystem locally via sshfs | ||
| - `umount(mountpoint, *, lazy=False)` - Unmount an sshfs filesystem (fallback for orphaned mounts) | ||
|
|
||
| ### Required Children | ||
|
|
||
| | Child name | Type | Description | | ||
| |-----------|------|-------------| | ||
| | `ssh` | `jumpstarter_driver_ssh.driver.SSHWrapper` | SSH driver providing credentials (username, identity key) and TCP connectivity. Must itself have a `tcp` child of type `TcpNetwork`. | | ||
|
|
||
| ### CLI | ||
|
|
||
| The driver registers as `mount` in the exporter config. When used in a `jmp shell` session, the CLI is a single command with a `--umount` flag for unmounting. | ||
|
raballew marked this conversation as resolved.
|
||
|
|
||
| Note: Each `-o` value is forwarded directly to sshfs as an `-o` option flag. You can | ||
| pass any option that sshfs (and by extension, the underlying SSH client) supports. | ||
| By default, the driver sets `StrictHostKeyChecking=no`, `UserKnownHostsFile=/dev/null`, | ||
| and `LogLevel=ERROR`. To override a default, pass the replacement via `-o` (e.g., | ||
| `-o StrictHostKeyChecking=yes`). Common options include `reconnect`, `cache=yes`, | ||
| `ServerAliveInterval=15`, and `compression=yes`. If you need other users on the | ||
| system to access the mounted filesystem, pass `-o allow_other` (requires | ||
| `user_allow_other` in `/etc/fuse.conf`). If `allow_other` fails due to FUSE | ||
| configuration, the mount will automatically retry without it. | ||
24 changes: 24 additions & 0 deletions
24
python/packages/jumpstarter-driver-ssh-mount/examples/exporter.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| apiVersion: jumpstarter.dev/v1alpha1 | ||
| kind: ExporterConfig | ||
| metadata: | ||
| namespace: default | ||
| name: demo | ||
| endpoint: grpc.jumpstarter.192.168.0.203.nip.io:8082 | ||
| token: "<token>" | ||
| export: | ||
| ssh: | ||
| type: jumpstarter_driver_ssh.driver.SSHWrapper | ||
| config: | ||
| default_username: "root" | ||
| # ssh_identity_file: "/path/to/key" | ||
| children: | ||
| tcp: | ||
| type: jumpstarter_driver_network.driver.TcpNetwork | ||
|
mangelajo marked this conversation as resolved.
|
||
| config: | ||
| host: "192.168.1.100" | ||
| port: 22 | ||
| mount: | ||
| type: jumpstarter_driver_ssh_mount.driver.SSHMount | ||
| children: | ||
| ssh: | ||
| ref: "ssh" | ||
1 change: 1 addition & 0 deletions
1
python/packages/jumpstarter-driver-ssh-mount/jumpstarter_driver_ssh_mount/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.