From 2ed984f1cdecafbe86e379fb98b74b2f6f1ad6d9 Mon Sep 17 00:00:00 2001 From: Wolf Vollprecht Date: Fri, 16 Oct 2020 09:16:02 +0200 Subject: [PATCH] fixes to make local registry (unauthenticated) usable --- binderhub/builder.py | 2 +- binderhub/health.py | 2 +- binderhub/registry.py | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/binderhub/builder.py b/binderhub/builder.py index bb727823d5..e41943d10c 100644 --- a/binderhub/builder.py +++ b/binderhub/builder.py @@ -291,7 +291,7 @@ async def get(self, provider_prefix, _unescaped_spec): if self.settings['use_registry']: for _ in range(3): try: - image_manifest = await self.registry.get_image_manifest(*'/'.join(image_name.split('/')[-2:]).split(':', 1)) + image_manifest = await self.registry.get_image_manifest(*'/'.join(image_name.split('/')[-2:]).rsplit(':', 1)) image_found = bool(image_manifest) break except HTTPClientError: diff --git a/binderhub/health.py b/binderhub/health.py index 00019d70c4..d92bc4fed2 100644 --- a/binderhub/health.py +++ b/binderhub/health.py @@ -133,7 +133,7 @@ async def check_docker_registry(self): # don't care if the image actually exists or not image_name = self.settings["image_prefix"] + "some-image-name:12345" await registry.get_image_manifest( - *'/'.join(image_name.split('/')[-2:]).split(':', 1) + *'/'.join(image_name.split('/')[-2:]).rsplit(':', 1) ) return True diff --git a/binderhub/registry.py b/binderhub/registry.py index 8891041b24..7a366dfef2 100644 --- a/binderhub/registry.py +++ b/binderhub/registry.py @@ -188,6 +188,10 @@ def _default_password(self): @gen.coroutine def get_image_manifest(self, image, tag): client = httpclient.AsyncHTTPClient() + if '/' in image: + # this handles the case of the image name including the registry + # e.g. localhost:32000/my-image + registry_prefix, image = image.split('/', 1) url = "{}/v2/{}/manifests/{}".format(self.url, image, tag) # first, get a token to perform the manifest request if self.token_url: