mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Retry instance start on error.
This commit is contained in:
parent
203e375449
commit
f3130898bb
1 changed files with 16 additions and 3 deletions
|
@ -248,10 +248,23 @@ class AnsibleCoreCI(object):
|
|||
'Content-Type': 'application/json',
|
||||
}
|
||||
|
||||
response = self.client.put(self._uri, data=json.dumps(data), headers=headers)
|
||||
tries = 2
|
||||
sleep = 10
|
||||
|
||||
if response.status_code != 200:
|
||||
raise self._create_http_error(response)
|
||||
while True:
|
||||
tries -= 1
|
||||
response = self.client.put(self._uri, data=json.dumps(data), headers=headers)
|
||||
|
||||
if response.status_code == 200:
|
||||
break
|
||||
|
||||
error = self._create_http_error(response)
|
||||
|
||||
if not tries:
|
||||
raise error
|
||||
|
||||
display.warning('%s. Trying again after %d seconds.' % (error, sleep))
|
||||
time.sleep(sleep)
|
||||
|
||||
self.started = True
|
||||
self._save()
|
||||
|
|
Loading…
Reference in a new issue