Skip to content

Commit

Permalink
have only symlink removed during remote cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenyu-ms committed Feb 18, 2025
1 parent 944cb0c commit 61635d7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
49 changes: 26 additions & 23 deletions testplan/common/remote/remote_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,25 +439,29 @@ def _prepare_workspace(self, exist_on_remote: bool) -> None:
self,
self.ssh_cfg["host"],
)
r, w = os.pipe()
rmt_non_existing = None
if 0 == self._execute_cmd_remote(
cmd="/bin/bash -c "
+ shlex.quote(
'e=""; for i in '
+ " ".join(
map(
shlex.quote,
self._workspace_paths.local.split(os.sep)[1:],
)
)
+ '; do e+="/${i}"; if [ ! -e "$e" ]; then echo "$e"; break; fi; done'
),
label="imitate local workspace path on remote - detect non-existing",
stdout=os.fdopen(w),
check=False, # XXX: bash might not be there
):
rmt_non_existing = os.fdopen(r).read().strip() or None
# TODO: uncomment later
# TODO: there is another issue related to created dir cleanup
# TODO: if push given, pushed files under created dir and delete_pushed
# TODO: set to False, what to do?
# r, w = os.pipe()
# if 0 == self._execute_cmd_remote(
# cmd="/bin/bash -c "
# + shlex.quote(
# 'e=""; for i in '
# + " ".join(
# map(
# shlex.quote,
# self._workspace_paths.local.split(os.sep)[1:],
# )
# )
# + '; do e+="/${i}"; if [ ! -e "$e" ]; then echo "$e"; break; fi; done'
# ),
# label="imitate local workspace path on remote - detect non-existing",
# stdout=os.fdopen(w),
# check=False, # XXX: bash might not be there
# ):
# rmt_non_existing = os.fdopen(r).read().strip() or None
if 0 == self._execute_cmd_remote(
cmd=mkdir_cmd(os.path.dirname(self._workspace_paths.local)),
label="imitate local workspace path on remote - mkdir",
Expand Down Expand Up @@ -662,11 +666,10 @@ def _clean_remote(self) -> None:
)

if self._dangling_remote_fs_obj:
# TODO: uncomment later
# self._execute_cmd_remote(
# cmd=rm_cmd(self._dangling_remote_fs_obj),
# label=f"Remove imitated workspace outside runpath",
# )
self._execute_cmd_remote(
cmd=rm_cmd(self._dangling_remote_fs_obj),
label=f"Remove imitated workspace outside runpath",
)
self._dangling_remote_fs_obj = None

if self.cfg.delete_pushed:
Expand Down
4 changes: 2 additions & 2 deletions testplan/runners/pools/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
UnboundRemoteResourceConfig,
)
from testplan.common.utils.logger import TESTPLAN_LOGGER
from testplan.common.utils.path import rebase_path
from testplan.common.utils.path import fix_home_prefix, rebase_path
from testplan.common.utils.remote import copy_cmd, ssh_cmd
from testplan.common.utils.timing import get_sleeper, wait

Expand Down Expand Up @@ -80,7 +80,7 @@ def host(self) -> str:

def _set_child_script(self) -> None:
"""Specify the remote worker executable file."""
self._child_paths.local = self._child_path()
self._child_paths.local = fix_home_prefix(self._child_path())
self._child_paths.remote = rebase_path(
self._child_paths.local,
self._testplan_import_path.local,
Expand Down

0 comments on commit 61635d7

Please sign in to comment.