Skip to content

Commit 224287b

Browse files
committed
Addressing feedback
1 parent 064226b commit 224287b

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

tmt/steps/execute/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,6 @@ def cleanup(self) -> None:
160160
self._rendered_script_path.unlink()
161161
self._rendered_script_path = None
162162

163-
def keep_rendered_file(self) -> None:
164-
"""Prevents automatic deletion on __exit__."""
165-
self._delete_on_exit = False
166-
167163

168164
def effective_scripts_dest_dir(default: Path = DEFAULT_SCRIPTS_DEST_DIR) -> Path:
169165
"""
@@ -839,7 +835,7 @@ def prepare_scripts(self, guest: "tmt.steps.provision.Guest") -> None:
839835
with script as source:
840836
# If it's a template, prevent immediate cleanup and track it
841837
if isinstance(script, ScriptTemplate):
842-
script.keep_rendered_file()
838+
script._delete_on_exit = False # Prevent cleanup before push
843839
templates_to_cleanup.append(script)
844840
# Use the actual rendered path as the source
845841
source_path = script._rendered_script_path

tmt/steps/provision/__init__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,22 +2447,19 @@ def push(
24472447
destination = Path("/")
24482448

24492449
sources: list[Path]
2450-
log_message: str
24512450

24522451
if source is None:
24532452
# FIXME: cast() - https://github.com/teemtee/tmt/issues/1372
24542453
parent = cast(Provision, self.parent)
24552454
assert parent.plan.workdir is not None
24562455
sources = [parent.plan.workdir]
2457-
log_message = f"Push workdir to guest '{self.primary_address}'."
2456+
self.debug(f"Push workdir to guest '{self.primary_address}'.")
24582457
elif isinstance(source, Path):
24592458
sources = [source]
2460-
log_message = f"Copy '{source}' to '{destination}' on the guest."
2459+
self.debug(f"Copy '{source}' to '{destination}' on the guest.")
24612460
else: # source is a list of Paths
24622461
sources = source
2463-
log_message = f"Copy {len(sources)} files/dirs to '{destination}' on the guest."
2464-
2465-
self.debug(log_message)
2462+
self.debug(f"Copy {len(sources)} files/dirs to '{destination}' on the guest.")
24662463

24672464
def rsync() -> None:
24682465
"""Run the rsync command"""

tmt/steps/provision/podman.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,12 @@ def push(
491491
for src in sources:
492492
source_spec = f"{container_name}:{src}" if container_name else str(src)
493493
dest_spec = f"{self.container}:{destination}"
494-
self.podman(Command("cp", source_spec, dest_spec))
494+
try:
495+
self.podman(Command("cp", source_spec, dest_spec))
496+
except tmt.utils.RunError as err:
497+
raise tmt.utils.ProvisionError(
498+
f"Failed to copy '{src}' to '{destination}': {err}"
499+
) from err
495500

496501
def pull(
497502
self,

0 commit comments

Comments
 (0)