1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Improve ansible-test error handling and timeouts. (#20328)

* Eliminate warning/retry on old instance check.
* Increase instance start timeout for windows.
This commit is contained in:
Matt Clay 2017-01-16 18:59:44 -08:00 committed by GitHub
parent 12628ed7e5
commit dbb89549ff
2 changed files with 10 additions and 7 deletions

View file

@ -81,7 +81,7 @@ class AnsibleCoreCI(object):
display.info('Checking existing %s/%s instance %s.' % (self.platform, self.version, self.instance_id),
verbosity=1)
self.connection = self.get()
self.connection = self.get(always_raise_on=[404])
display.info('Loaded existing %s/%s instance %s.' % (self.platform, self.version, self.instance_id),
verbosity=1)
@ -159,9 +159,12 @@ class AnsibleCoreCI(object):
raise self._create_http_error(response)
def get(self):
def get(self, tries=2, sleep=10, always_raise_on=None):
"""
Get instance connection information.
:type tries: int
:type sleep: int
:type always_raise_on: list[int] | None
:rtype: InstanceConnection
"""
if not self.started:
@ -169,12 +172,12 @@ class AnsibleCoreCI(object):
verbosity=1)
return None
if not always_raise_on:
always_raise_on = []
if self.connection and self.connection.running:
return self.connection
tries = 2
sleep = 10
while True:
tries -= 1
response = self.client.get(self._uri)
@ -184,7 +187,7 @@ class AnsibleCoreCI(object):
error = self._create_http_error(response)
if not tries:
if not tries or response.status_code in always_raise_on:
raise error
display.warning('%s. Trying again after %d seconds.' % (error, sleep))

View file

@ -47,7 +47,7 @@ class ManageWindowsCI(object):
env = ansible_environment(self.core_ci.args)
cmd = ['ansible', '-m', 'win_ping', '-i', '%s,' % name, name, '-e', ' '.join(extra_vars)]
for _ in range(1, 90):
for _ in range(1, 120):
try:
run_command(self.core_ci.args, cmd, env=env)
return