[ARVADOS] updated: 2.1.0-1490-g6fe5fe411
Git user
git at public.arvados.org
Wed Oct 13 20:27:42 UTC 2021
Summary of changes:
sdk/python/arvados/commands/keepdocker.py | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
via 6fe5fe41128cfe4fc9b5b6f6c1f092c4d01c4e4e (commit)
from 4e142b5282d5e620057e06530f58445d2a526964 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 6fe5fe41128cfe4fc9b5b6f6c1f092c4d01c4e4e
Author: Peter Amstutz <peter.amstutz at curii.com>
Date: Wed Oct 13 15:34:29 2021 -0400
Use docker inspect instead of iterating over images list
refs #18238
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>
diff --git a/sdk/python/arvados/commands/keepdocker.py b/sdk/python/arvados/commands/keepdocker.py
index f3df4e3f3..537ea3a94 100644
--- a/sdk/python/arvados/commands/keepdocker.py
+++ b/sdk/python/arvados/commands/keepdocker.py
@@ -87,9 +87,9 @@ def popen_docker(cmd, *args, **kwargs):
kwargs.setdefault('stdin', subprocess.PIPE)
kwargs.setdefault('stdout', sys.stderr)
try:
- docker_proc = subprocess.Popen(['docker.io'] + cmd, *args, **kwargs)
- except OSError: # No docker.io in $PATH
docker_proc = subprocess.Popen(['docker'] + cmd, *args, **kwargs)
+ except OSError: # No docker in $PATH, try docker.io
+ docker_proc = subprocess.Popen(['docker.io'] + cmd, *args, **kwargs)
if manage_stdin:
docker_proc.stdin.close()
return docker_proc
@@ -146,20 +146,18 @@ def docker_images():
check_docker(list_proc, "images")
def find_image_hashes(image_search, image_tag=None):
- # Given one argument, search for Docker images with matching hashes,
- # and return their full hashes in a set.
- # Given two arguments, also search for a Docker image with the
- # same repository and tag. If one is found, return its hash in a
- # set; otherwise, fall back to the one-argument hash search.
- # Returns None if no match is found, or a hash search is ambiguous.
- hash_search = image_search.lower()
- hash_matches = set()
- for image in docker_images():
- if (image.repo == image_search) and (image.tag == image_tag):
- return set([image.hash])
- elif image.hash.startswith(hash_search):
- hash_matches.add(image.hash)
- return hash_matches
+ # Query for a Docker images with the repository and tag and return
+ # the image ids in a list. Returns empty list if no match is
+ # found.
+
+ list_proc = popen_docker(['inspect', "%s%s" % (image_search, ":"+image_tag if image_tag else "")], stdout=subprocess.PIPE)
+
+ inspect = list_proc.stdout.read()
+ list_proc.stdout.close()
+
+ imageinfo = json.loads(inspect)
+
+ return [i["Id"] for i in imageinfo]
def find_one_image_hash(image_search, image_tag=None):
hashes = find_image_hashes(image_search, image_tag)
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list