aktualizr: retry garage-sign version check and handle errors better.
@@ -11,8 +11,21 @@ python () {
url = url_file.read().decode().strip(' \t\n') + '/health/version'
except (KeyError, ValueError, RuntimeError):
return
+ connected = False
+ tries = 3
+ for i in range(tries):
+ try:
r = urllib.request.urlopen(url)
- if r.code != 200:
+ if r.code == 200:
+ connected = True
+ break
+ else:
+ print('Bad return code from server ' + url + ': ' + str(r.code) +
+ ' (attempt ' + str(i + 1) + ' of ' + str(tries) + ')')
+ except urllib.error.URLError as e:
+ print('Error connecting to server ' + url + ': ' + str(e) +
+ ' (attempt ' + str(i + 1) + ' of ' + str(tries) + ')')
+ if not connected:
return
resp = r.read().decode('utf-8')
j = json.loads(resp)
