-
Notifications
You must be signed in to change notification settings - Fork 4.2k
fix(mounts): resolve rclone remote names consistently #3624
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -739,6 +739,7 @@ async def _start_rclone_server( | |
| *, | ||
| config: RcloneMountConfig, | ||
| config_path: Path, | ||
| remote_name: str, | ||
| nfs_addr: str, | ||
| ) -> None: | ||
| nfs_check = await session.exec( | ||
|
|
@@ -753,7 +754,7 @@ async def _start_rclone_server( | |
| tool="rclone serve nfs", | ||
| context={"type": config.mount_type}, | ||
| ) | ||
| cmd: list[str] = ["rclone", "serve", "nfs", f"{config.remote_name}:{config.remote_path}"] | ||
| cmd: list[str] = ["rclone", "serve", "nfs", f"{remote_name}:{config.remote_path}"] | ||
| cmd.extend(["--addr", nfs_addr]) | ||
| cmd.extend(["--config", sandbox_path_str(config_path)]) | ||
| if config.read_only: | ||
|
|
@@ -778,13 +779,14 @@ async def _start_rclone_client( | |
| path: Path, | ||
| config: RcloneMountConfig, | ||
| config_path: Path, | ||
| remote_name: str, | ||
| nfs_addr: str | None = None, | ||
| ) -> None: | ||
| if self.mode == "fuse": | ||
| cmd: list[str] = [ | ||
| "rclone", | ||
| "mount", | ||
| f"{config.remote_name}:{config.remote_path}", | ||
| f"{remote_name}:{config.remote_path}", | ||
| sandbox_path_str(path), | ||
| ] | ||
| if config.read_only: | ||
|
|
@@ -900,12 +902,13 @@ async def apply( | |
| context={"type": rclone_config.mount_type}, | ||
| ) | ||
| session_id_str = session_id.hex | ||
| remote_name = rclone_config.remote_name | ||
| # Keep generated rclone config under the workspace root so `session.mkdir()` / | ||
| # `session.write()` can handle it without special-casing absolute paths. | ||
| config_dir = posix_path_as_path( | ||
| coerce_posix_path(f".sandbox-rclone-config/{session_id_str}") | ||
| ) | ||
| config_path = config_dir / f"{rclone_config.remote_name}.conf" | ||
| config_path = config_dir / f"{remote_name}.conf" | ||
| await session.mkdir(path, parents=True) | ||
| await session.mkdir(config_dir, parents=True) | ||
| session.register_persist_workspace_skip_path(config_dir) | ||
|
|
@@ -924,13 +927,15 @@ async def apply( | |
| session, | ||
| config=rclone_config, | ||
| config_path=command_config_path, | ||
| remote_name=remote_name, | ||
| nfs_addr=nfs_addr, | ||
| ) | ||
| await self._start_rclone_client( | ||
| session, | ||
| path=path, | ||
| config=rclone_config, | ||
| config_path=command_config_path, | ||
| remote_name=remote_name, | ||
| nfs_addr=nfs_addr, | ||
| ) | ||
| else: | ||
|
|
@@ -940,6 +945,7 @@ async def apply( | |
| path=path, | ||
| config=rclone_config, | ||
| config_path=command_config_path, | ||
| remote_name=remote_name, | ||
| ) | ||
|
|
||
| async def unapply( | ||
|
|
@@ -965,12 +971,22 @@ async def unapply( | |
| shell=False, | ||
| ) | ||
|
|
||
| session_id = getattr(session.state, "session_id", None) | ||
| if session_id is None: | ||
| remote_name = rclone_config.remote_name | ||
| else: | ||
| remote_name = self.resolve_remote_name( | ||
| session_id=session_id.hex, | ||
| remote_kind=rclone_config.remote_kind, | ||
| mount_type=rclone_config.mount_type, | ||
| ) | ||
|
Comment on lines
+978
to
+982
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For mounts where the pattern-level or derived name differs from Useful? React with 👍 / 👎. |
||
|
|
||
| await session.exec( | ||
| "sh", | ||
| "-lc", | ||
| ( | ||
| "pkill -f -- " | ||
| f"'rclone (mount|serve nfs) {rclone_config.remote_name}:' >/dev/null 2>&1 || true" | ||
| f"'rclone (mount|serve nfs) {remote_name}:' >/dev/null 2>&1 || true" | ||
| ), | ||
| shell=False, | ||
| ) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When any rclone mount is applied, the default fuse path calls
_start_rclone_client(), but this helper has noremote_nameparameter or local binding, so evaluating this f-string raisesNameErrorbefore rclone is invoked. The NFS server helper has the same issue, so this change currently breaks rclone mounts instead of just changing name resolution.Useful? React with 👍 / 👎.