From dbb89549fffc38cded8141ce661a094a50b18360 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Mon, 16 Jan 2017 18:59:44 -0800 Subject: [PATCH] Improve ansible-test error handling and timeouts. (#20328) * Eliminate warning/retry on old instance check. * Increase instance start timeout for windows. --- test/runner/lib/core_ci.py | 15 +++++++++------ test/runner/lib/manage_ci.py | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/test/runner/lib/core_ci.py b/test/runner/lib/core_ci.py index 71968e1e880..98756e22129 100644 --- a/test/runner/lib/core_ci.py +++ b/test/runner/lib/core_ci.py @@ -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)) diff --git a/test/runner/lib/manage_ci.py b/test/runner/lib/manage_ci.py index 2d0bb5cf343..0966642e2e3 100644 --- a/test/runner/lib/manage_ci.py +++ b/test/runner/lib/manage_ci.py @@ -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