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:
parent
12628ed7e5
commit
dbb89549ff
2 changed files with 10 additions and 7 deletions
|
@ -81,7 +81,7 @@ class AnsibleCoreCI(object):
|
||||||
display.info('Checking existing %s/%s instance %s.' % (self.platform, self.version, self.instance_id),
|
display.info('Checking existing %s/%s instance %s.' % (self.platform, self.version, self.instance_id),
|
||||||
verbosity=1)
|
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),
|
display.info('Loaded existing %s/%s instance %s.' % (self.platform, self.version, self.instance_id),
|
||||||
verbosity=1)
|
verbosity=1)
|
||||||
|
@ -159,9 +159,12 @@ class AnsibleCoreCI(object):
|
||||||
|
|
||||||
raise self._create_http_error(response)
|
raise self._create_http_error(response)
|
||||||
|
|
||||||
def get(self):
|
def get(self, tries=2, sleep=10, always_raise_on=None):
|
||||||
"""
|
"""
|
||||||
Get instance connection information.
|
Get instance connection information.
|
||||||
|
:type tries: int
|
||||||
|
:type sleep: int
|
||||||
|
:type always_raise_on: list[int] | None
|
||||||
:rtype: InstanceConnection
|
:rtype: InstanceConnection
|
||||||
"""
|
"""
|
||||||
if not self.started:
|
if not self.started:
|
||||||
|
@ -169,12 +172,12 @@ class AnsibleCoreCI(object):
|
||||||
verbosity=1)
|
verbosity=1)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
if not always_raise_on:
|
||||||
|
always_raise_on = []
|
||||||
|
|
||||||
if self.connection and self.connection.running:
|
if self.connection and self.connection.running:
|
||||||
return self.connection
|
return self.connection
|
||||||
|
|
||||||
tries = 2
|
|
||||||
sleep = 10
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
tries -= 1
|
tries -= 1
|
||||||
response = self.client.get(self._uri)
|
response = self.client.get(self._uri)
|
||||||
|
@ -184,7 +187,7 @@ class AnsibleCoreCI(object):
|
||||||
|
|
||||||
error = self._create_http_error(response)
|
error = self._create_http_error(response)
|
||||||
|
|
||||||
if not tries:
|
if not tries or response.status_code in always_raise_on:
|
||||||
raise error
|
raise error
|
||||||
|
|
||||||
display.warning('%s. Trying again after %d seconds.' % (error, sleep))
|
display.warning('%s. Trying again after %d seconds.' % (error, sleep))
|
||||||
|
|
|
@ -47,7 +47,7 @@ class ManageWindowsCI(object):
|
||||||
env = ansible_environment(self.core_ci.args)
|
env = ansible_environment(self.core_ci.args)
|
||||||
cmd = ['ansible', '-m', 'win_ping', '-i', '%s,' % name, name, '-e', ' '.join(extra_vars)]
|
cmd = ['ansible', '-m', 'win_ping', '-i', '%s,' % name, name, '-e', ' '.join(extra_vars)]
|
||||||
|
|
||||||
for _ in range(1, 90):
|
for _ in range(1, 120):
|
||||||
try:
|
try:
|
||||||
run_command(self.core_ci.args, cmd, env=env)
|
run_command(self.core_ci.args, cmd, env=env)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue