1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-02-04 07:11:49 +00:00

Fix file copy in buildah

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
Sagi Shnaidman 2025-08-07 12:38:58 +03:00
parent ed1c5f5f42
commit 3aa2a46c94

View file

@ -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)