[arvados] created: 2.1.0-3174-ged948e5ff

git repository hosting git at public.arvados.org
Thu Dec 8 22:24:30 UTC 2022


        at  ed948e5ff97e22594d54845097dbea77048aa2fc (commit)


commit ed948e5ff97e22594d54845097dbea77048aa2fc
Author: Tom Clegg <tom at curii.com>
Date:   Thu Dec 8 17:23:53 2022 -0500

    19840: Test listing saved images with names containing port numbers.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/sdk/python/tests/test_arv_keepdocker.py b/sdk/python/tests/test_arv_keepdocker.py
index 9ce096fb5..8dea29a44 100644
--- a/sdk/python/tests/test_arv_keepdocker.py
+++ b/sdk/python/tests/test_arv_keepdocker.py
@@ -25,12 +25,12 @@ class StopTest(Exception):
 
 
 class ArvKeepdockerTestCase(unittest.TestCase, tutil.VersionChecker):
-    def run_arv_keepdocker(self, args, err):
+    def run_arv_keepdocker(self, args, err, **kwargs):
         sys.argv = ['arv-keepdocker'] + args
         log_handler = logging.StreamHandler(err)
         arv_keepdocker.logger.addHandler(log_handler)
         try:
-            return arv_keepdocker.main()
+            return arv_keepdocker.main(**kwargs)
         finally:
             arv_keepdocker.logger.removeHandler(log_handler)
 
@@ -167,6 +167,17 @@ class ArvKeepdockerTestCase(unittest.TestCase, tutil.VersionChecker):
             self.run_arv_keepdocker(['[::1]:8888/repo/img:tag'], sys.stderr)
         find_image_mock.assert_called_with('[::1]:8888/repo/img', 'tag')
 
+    def test_list_images_with_host_and_port(self):
+        arvados.api('v1').links().create(body={'link': {
+            'link_class': 'docker_image_repo+tag',
+            'name': 'registry.example:1234/repo:latest',
+            'head_uuid': 'zzzzz-4zz18-1v45jub259sjjgb',
+        }}).execute()
+        out = tutil.StringIO()
+        with self.assertRaises(SystemExit):
+            self.run_arv_keepdocker([], sys.stderr, stdout=out)
+        self.assertRegex(out.getvalue(), '\nregistry.example:1234/repo +latest ')
+
     @mock.patch('arvados.commands.keepdocker.list_images_in_arv',
                 return_value=[])
     @mock.patch('arvados.commands.keepdocker.find_image_hashes',

commit 8363d828ffd8a190ba41b6b9d435a292a4a8f0a5
Author: Tom Clegg <tom at curii.com>
Date:   Thu Dec 8 16:52:52 2022 -0500

    19840: Fix image name confusion when specified with explicit :443.
    
    Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom at curii.com>

diff --git a/sdk/python/arvados/commands/keepdocker.py b/sdk/python/arvados/commands/keepdocker.py
index db4edd2df..2d5c0150c 100644
--- a/sdk/python/arvados/commands/keepdocker.py
+++ b/sdk/python/arvados/commands/keepdocker.py
@@ -326,7 +326,7 @@ def list_images_in_arv(api_client, num_retries, image_name=None, image_tag=None,
             dockerhash = hash_link_map[collection_uuid]['name']
         except KeyError:
             dockerhash = '<unknown>'
-        name_parts = link['name'].split(':', 1)
+        name_parts = link['name'].rsplit(':', 1)
         images.append(_new_image_listing(link, dockerhash, *name_parts))
 
     # Find any image hash links that did not have a corresponding name link,
@@ -386,6 +386,16 @@ def main(arguments=None, stdout=sys.stdout, install_sig_handlers=True, api=None)
     elif args.tag is None:
         args.tag = 'latest'
 
+    if '/' in args.image:
+        hostport, path = args.image.split('/', 1)
+        if hostport.endswith(':443'):
+            # "docker pull host:443/asdf" transparently removes the
+            # :443 (which is redundant because https is implied) and
+            # after it succeeds "docker images" will list "host/asdf",
+            # not "host:443/asdf".  If we strip the :443 then the name
+            # doesn't change underneath us.
+            args.image = '/'.join([hostport[:-4], path])
+
     # Pull the image if requested, unless the image is specified as a hash
     # that we already have.
     if args.pull and not find_image_hashes(args.image):
diff --git a/sdk/python/tests/test_arv_keepdocker.py b/sdk/python/tests/test_arv_keepdocker.py
index 8fbfad437..9ce096fb5 100644
--- a/sdk/python/tests/test_arv_keepdocker.py
+++ b/sdk/python/tests/test_arv_keepdocker.py
@@ -135,12 +135,19 @@ class ArvKeepdockerTestCase(unittest.TestCase, tutil.VersionChecker):
             self.run_arv_keepdocker(['repo:tag'], sys.stderr)
         find_image_mock.assert_called_with('repo', 'tag')
 
+    def test_image_given_as_registry_repo_colon_tag(self):
         with self.assertRaises(StopTest), \
              mock.patch('arvados.commands.keepdocker.find_one_image_hash',
                         side_effect=StopTest) as find_image_mock:
             self.run_arv_keepdocker(['myreg.example:8888/repo/img:tag'], sys.stderr)
         find_image_mock.assert_called_with('myreg.example:8888/repo/img', 'tag')
 
+        with self.assertRaises(StopTest), \
+             mock.patch('arvados.commands.keepdocker.find_one_image_hash',
+                        side_effect=StopTest) as find_image_mock:
+            self.run_arv_keepdocker(['registry.hub.docker.com:443/library/debian:bullseye-slim'], sys.stderr)
+        find_image_mock.assert_called_with('registry.hub.docker.com/library/debian', 'bullseye-slim')
+
     def test_image_has_colons(self):
         with self.assertRaises(StopTest), \
              mock.patch('arvados.commands.keepdocker.find_one_image_hash',
@@ -154,6 +161,12 @@ class ArvKeepdockerTestCase(unittest.TestCase, tutil.VersionChecker):
             self.run_arv_keepdocker(['[::1]/repo/img'], sys.stderr)
         find_image_mock.assert_called_with('[::1]/repo/img', 'latest')
 
+        with self.assertRaises(StopTest), \
+             mock.patch('arvados.commands.keepdocker.find_one_image_hash',
+                        side_effect=StopTest) as find_image_mock:
+            self.run_arv_keepdocker(['[::1]:8888/repo/img:tag'], sys.stderr)
+        find_image_mock.assert_called_with('[::1]:8888/repo/img', 'tag')
+
     @mock.patch('arvados.commands.keepdocker.list_images_in_arv',
                 return_value=[])
     @mock.patch('arvados.commands.keepdocker.find_image_hashes',

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list