From 3aa2a46c94aebf61acefdf5ae123ea8399da4831 Mon Sep 17 00:00:00 2001 From: Sagi Shnaidman Date: Thu, 7 Aug 2025 12:38:58 +0300 Subject: [PATCH] Fix file copy in buildah Signed-off-by: Sagi Shnaidman --- plugins/connection/buildah.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/connection/buildah.py b/plugins/connection/buildah.py index 4a67861..e4a4bd4 100644 --- a/plugins/connection/buildah.py +++ b/plugins/connection/buildah.py @@ -423,6 +423,12 @@ class Connection(ConnectionBase): shutil.chown(real_out_path, user=self.get_option("remote_user")) except (OSError, LookupError) as e: display.vvv(f"Could not change ownership via mount: {e}", host=self._container_id) + # Remove the file and fall back to buildah copy + try: + os.remove(real_out_path) + except OSError: + pass + raise Exception("Ownership change failed, falling back to buildah copy") return except Exception as e: display.vvv(f"Mount copy failed, falling back to buildah copy: {e}", host=self._container_id)