@@ -35,23 +35,29 @@ class DockerRepoAdapter:
35
35
def __init__ (self , registry_endpoint = "https://hub.docker.com" ):
36
36
self .registry_endpoint = registry_endpoint
37
37
38
- def check_image_exists (self , tagged_image : str ) -> bool :
38
+ def check_image_exists (self , tagged_image : str ) -> ( bool , str ) :
39
39
"""
40
40
Checks that the given Docker image
41
41
:param tagged_image: Full Docker image name, e.g. "sslhep/servicex_app:latest".
42
42
:return: Whether or not the image exists in the registry.
43
43
"""
44
44
search_result = re .search ("(.+)/(.+):(.+)" , tagged_image )
45
45
if not search_result or len (search_result .groups ()) != 3 :
46
- return False
46
+ return False , f"Requested transformer docker image is not in the right format: { tagged_image } "
47
47
48
48
(repo , image , tag ) = search_result .groups ()
49
49
50
50
query = f'{ self .registry_endpoint } /v2/repositories/{ repo } /{ image } /tags/{ tag } '
51
51
r = requests .get (query )
52
+
53
+ if r .status_code >= 200 and r .status_code < 300 :
54
+ current_app .logger .info (f"Requested Image: { tagged_image } exists, "
55
+ f"last updated { r .json ()['last_updated' ]} " )
56
+ return True , ""
57
+
52
58
if r .status_code == 404 :
53
- return False
59
+ return False , f"Requested transformer docker image doesn't exist: { tagged_image } "
60
+
61
+ msg = f"Unexpected error in validating transformer docker image ({ tagged_image } ), status_code: { r .status_code } , msg ({ r .content } )"
62
+ return False , msg
54
63
55
- current_app .logger .info (f"Requested Image: { tagged_image } exists, "
56
- f"last updated { r .json ()['last_updated' ]} " )
57
- return True
0 commit comments