From 3807db1b6ebc8d65ddc64f450d933fab2121e7eb Mon Sep 17 00:00:00 2001 From: Sean Eagan Date: Fri, 1 Mar 2019 14:24:13 -0600 Subject: [PATCH] Fail wait when no resources found This removees a fail-safe that allowed releases which did not contain pods (intentionally) to still succeed after a best effort to wait for them until timeout. Now that we have the ability to disable waiting on resource types `wait.resources` [0], this fail-safe is no longer needed. Now when resources are not found, armada will fail with a message for the user to check their `wait.resources` and labels and configure as needed. This way we can prompt the user to remove unnecessary waiting from their deployments. There is also a longer term plan to make these configurations less often needed [1]. [0]: https://review.openstack.org/#/c/603901/ [1]: https://review.openstack.org/#/c/636440/ Change-Id: I859326470ecba49f2301705409c51312a601e653 --- armada/handlers/wait.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/armada/handlers/wait.py b/armada/handlers/wait.py index 721d6a1f..f6e46ebc 100644 --- a/armada/handlers/wait.py +++ b/armada/handlers/wait.py @@ -216,22 +216,22 @@ class ResourceWait(ABC): timed_out, modified, unready, found_resources = ( self._watch_resource_completions(timeout=deadline_remaining)) - if not found_resources: - if self.skip_if_none_found: - return - else: - LOG.warn( - 'Saw no resources for ' - 'resource type=%s, namespace=%s, labels=(%s). Are the ' - 'labels correct?', self.resource_type, - self.chart_wait.namespace, self.label_selector) - # TODO(seaneagan): Should probably fail here even when resources - # were not found, at least once we have an option to ignore - # wait timeouts. - if timed_out and found_resources: - error = "Timed out waiting for resources={}".format( - sorted(unready)) + if (not found_resources) and self.skip_if_none_found: + return + + if timed_out: + if not found_resources: + details = ('None found! Are `wait.labels` correct? Does ' + '`wait.resources` need to exclude %s?'.format( + self.resource_type)) + else: + details = ('These {}s were not ready={}'.format( + self.resource_type, sorted(unready))) + error = ( + 'Timed out waiting for {}s (namespace={}, labels=({})). {}' + .format(self.resource_type, self.chart_wait.namespace, + self.label_selector, details)) LOG.error(error) raise k8s_exceptions.KubernetesWatchTimeoutException(error)