def check_registry_status(url=DEFAULT_IMAGES_URL, _v2=False):
"""
Performs api check for registry health status.
:params url: registry url
:raises RegistryError: if registry is not available
"""
url = urlsplit(url)._replace(path='/v2/' if _v2 else '/v1/_ping').geturl()
with raise_registry_error(url):
response = requests.get(url, timeout=PING_REQUEST_TIMEOUT,
verify=False)
need_v2 = not _v2 and response.status_code == 404 and \
response.headers.get(API_VERSION_HEADER) == 'registry/2.0'
if need_v2:
check_registry_status(url, _v2=True)
elif response.status_code == 401:
return # user is not authorized, but registry is available
else:
response.raise_for_status()
评论列表
文章目录