X-Git-Url: https://git.adam-barratt.org.uk/?a=blobdiff_plain;f=modules%2Froles%2Ffiles%2Fmirror_health%2Fmirror-health;fp=modules%2Froles%2Ffiles%2Fmirror_health%2Fmirror-health;h=bbd4c2787768291ecc37ed7b748c309e3dc18d02;hb=76ca91bce24ecbcbcc4e62a37aa06fd0fb9f96c7;hp=c3606de0018c6930bb1705c6599c30c332d5795e;hpb=46cee04ab06b23ab6e9e4baba655cf470d10cfc4;p=mirror%2Fdsa-puppet.git diff --git a/modules/roles/files/mirror_health/mirror-health b/modules/roles/files/mirror_health/mirror-health index c3606de00..bbd4c2787 100755 --- a/modules/roles/files/mirror_health/mirror-health +++ b/modules/roles/files/mirror_health/mirror-health @@ -21,7 +21,8 @@ def retrieve_from_host(host, url): 'http': 'http://{}:80'.format(host), 'https': 'http://{}:443'.format(host), } - return requests.get(url, timeout=5, proxies=proxies, allow_redirects=False) + headers = {'User-Agent': 'mirror-health'} + return requests.get(url, headers=headers, timeout=5, proxies=proxies, allow_redirects=False) def last_modified(response): lm = 0 @@ -48,11 +49,11 @@ def check_uptodate(): logging.debug("lm for host %s: %s", host, lm) if healthy(retrieve_from_host(host, HEALTH_CHECK_URL)): latest_ts = max(latest_ts, lm) - except (requests.exceptions.ProxyError, requests.exceptions.ReadTimeout, requests.exceptions.ConnectTimeout): + except (requests.exceptions.ProxyError, requests.exceptions.ReadTimeout, requests.exceptions.ConnectTimeout, requests.exceptions.ConnectionError): pass try: local_lm = last_modified(retrieve_from_host('localhost', URL)) - except (requests.exceptions.ProxyError, requests.exceptions.ReadTimeout, requests.exceptions.ConnectTimeout): + except (requests.exceptions.ProxyError, requests.exceptions.ReadTimeout, requests.exceptions.ConnectTimeout, requests.exceptions.ConnectionError): return False logging.debug("lm for localhost: %s", local_lm) if local_lm < latest_ts: