Skip to content

Commit

Permalink
Merge branch 'cesanta-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
shin- committed Jun 19, 2015
2 parents 7118b1f + 8f43c03 commit f40e034
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions docker/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,21 @@ def compare_version(v1, v2):


def ping_registry(url):
return ping(url + '/v2/') or ping(url + '/v1/_ping')
return ping(url + '/v2/', [401]) or ping(url + '/v1/_ping')


def ping(url):
def ping(url, valid_4xx_statuses=None):
try:
res = requests.get(url, timeout=3)
except Exception:
return False
else:
return res.status_code < 400
# We don't send yet auth headers
# and a v2 registry will respond with status 401
return (
res.status_code < 400 or
(valid_4xx_statuses and res.status_code in valid_4xx_statuses)
)


def _convert_port_binding(binding):
Expand Down

0 comments on commit f40e034

Please sign in to comment.