From f13f3d11dc624b9950ad6da2e44f8dfedd7709ea Mon Sep 17 00:00:00 2001 From: wahabk Date: Tue, 17 Dec 2024 16:18:28 +0000 Subject: [PATCH 1/3] remove transport prefix in `pull` --- podman_hpc/podman_hpc.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/podman_hpc/podman_hpc.py b/podman_hpc/podman_hpc.py index 38b7ae3..7ad00b6 100755 --- a/podman_hpc/podman_hpc.py +++ b/podman_hpc/podman_hpc.py @@ -207,6 +207,12 @@ def images(ctx, siteconf, image, podman_args, **site_opts): @click.argument("image") def pull(ctx, siteconf, image, podman_args, **site_opts): """Pulls an image to a local repository and makes a squashed copy.""" + # Check for transport_prefix + if "://" in image: + transport_prefix, image = image.split("://", 1) + else: + transport_prefix = None + cmd = [siteconf.podman_bin, "pull"] cmd.extend(podman_args) cmd.extend(siteconf.get_cmd_extensions("pull", site_opts)) From 1e3978ec91a7b77e1d71ee83e9f6253ecce830b9 Mon Sep 17 00:00:00 2001 From: wahabk Date: Tue, 17 Dec 2024 16:26:02 +0000 Subject: [PATCH 2/3] remove prefix after subprocess --- podman_hpc/podman_hpc.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/podman_hpc/podman_hpc.py b/podman_hpc/podman_hpc.py index 7ad00b6..3d8e3b7 100755 --- a/podman_hpc/podman_hpc.py +++ b/podman_hpc/podman_hpc.py @@ -206,19 +206,20 @@ def images(ctx, siteconf, image, podman_args, **site_opts): @click.argument("podman_args", nargs=-1, type=click.UNPROCESSED) @click.argument("image") def pull(ctx, siteconf, image, podman_args, **site_opts): - """Pulls an image to a local repository and makes a squashed copy.""" - # Check for transport_prefix - if "://" in image: - transport_prefix, image = image.split("://", 1) - else: - transport_prefix = None - + """Pulls an image to a local repository and makes a squashed copy.""" cmd = [siteconf.podman_bin, "pull"] cmd.extend(podman_args) cmd.extend(siteconf.get_cmd_extensions("pull", site_opts)) cmd.append(image) proc = Popen(cmd) proc.communicate() + + # Check for transport_prefix + if "://" in image: + transport_prefix, image = image.split("://", 1) + else: + transport_prefix = None + if proc.returncode == 0: sys.stdout.write(f"INFO: Migrating image to {siteconf.squash_dir}\n") mu = MigrateUtils(conf=siteconf) From 01fff4ae15573675595022cd3af3dd07dcd33c6e Mon Sep 17 00:00:00 2001 From: wahabk Date: Mon, 3 Feb 2025 16:05:16 +0000 Subject: [PATCH 3/3] scanon review, check "docker://" --- podman_hpc/podman_hpc.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/podman_hpc/podman_hpc.py b/podman_hpc/podman_hpc.py index 3d8e3b7..091ab5e 100755 --- a/podman_hpc/podman_hpc.py +++ b/podman_hpc/podman_hpc.py @@ -194,6 +194,14 @@ def images(ctx, siteconf, image, podman_args, **site_opts): cmd.extend(podman_args) cmd.extend(siteconf.get_cmd_extensions("images", site_opts)) +PODMAN_TRANSPORT_PREFIXES = [ + "docker://", + "dir:", + "docker-archive:", + "docker-daemon:", + "oci-archive:", +] + # podman-hpc pull subcommand (modified) #################################### @podhpc.command( context_settings=dict( @@ -206,7 +214,7 @@ def images(ctx, siteconf, image, podman_args, **site_opts): @click.argument("podman_args", nargs=-1, type=click.UNPROCESSED) @click.argument("image") def pull(ctx, siteconf, image, podman_args, **site_opts): - """Pulls an image to a local repository and makes a squashed copy.""" + """Pulls an image to a local repository and makes a squashed copy.""" cmd = [siteconf.podman_bin, "pull"] cmd.extend(podman_args) cmd.extend(siteconf.get_cmd_extensions("pull", site_opts)) @@ -215,10 +223,15 @@ def pull(ctx, siteconf, image, podman_args, **site_opts): proc.communicate() # Check for transport_prefix - if "://" in image: - transport_prefix, image = image.split("://", 1) - else: - transport_prefix = None + for prefix in PODMAN_TRANSPORT_PREFIXES: + if image.startswith(prefix): + if prefix != "docker://": + sys.stderr.write( + f"""WARNING: Transport prefix '{prefix}' is + incompatible with podman-hpc.\n""" + ) + image = image[len(prefix):] # Remove the prefix + break if proc.returncode == 0: sys.stdout.write(f"INFO: Migrating image to {siteconf.squash_dir}\n")