From d7fd32325e8ea3b7e0397e031fee5d8e47ae4d7c Mon Sep 17 00:00:00 2001 From: Shane Canon Date: Thu, 10 Mar 2022 16:39:43 -0800 Subject: [PATCH 1/2] Handle more auth responses --- imagegw/shifter_imagegw/dockerv2_ext.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/imagegw/shifter_imagegw/dockerv2_ext.py b/imagegw/shifter_imagegw/dockerv2_ext.py index e63f28f8..85269172 100644 --- a/imagegw/shifter_imagegw/dockerv2_ext.py +++ b/imagegw/shifter_imagegw/dockerv2_ext.py @@ -105,9 +105,9 @@ def _inspect(self): process = Popen(cmd, stdout=PIPE, stderr=PIPE) stdout, stderr = process.communicate() stderr_str = stderr.decode("utf-8") - if 'authentication required' not in stderr_str and 'Forbidden' not in stderr_str: - if process.returncode: - raise OSError("Skopeo inspect failed") + auth_errors = ['authentication', 'forbidden', 'unauthorized'] + if not any(a_err in stderr_str.lower() for a_err in auth_errors): + raise OSError("Skopeo inspect failed: %s" % (stderr_str)) return json.loads(stdout.decode("utf-8")) # Private Image From d6a187671ca7383643169feb8c9b4d8c895a8231 Mon Sep 17 00:00:00 2001 From: Shane Canon Date: Thu, 10 Mar 2022 16:47:15 -0800 Subject: [PATCH 2/2] Handle more auth responses --- imagegw/shifter_imagegw/dockerv2_ext.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/imagegw/shifter_imagegw/dockerv2_ext.py b/imagegw/shifter_imagegw/dockerv2_ext.py index 85269172..aa2ccb91 100644 --- a/imagegw/shifter_imagegw/dockerv2_ext.py +++ b/imagegw/shifter_imagegw/dockerv2_ext.py @@ -106,7 +106,10 @@ def _inspect(self): stdout, stderr = process.communicate() stderr_str = stderr.decode("utf-8") auth_errors = ['authentication', 'forbidden', 'unauthorized'] + # see if we got some type of unauthorized response if not any(a_err in stderr_str.lower() for a_err in auth_errors): + # See if it exited with an error + if process.returncode: raise OSError("Skopeo inspect failed: %s" % (stderr_str)) return json.loads(stdout.decode("utf-8"))