From 8d74042c30ed9bd3964e08cb87141b7502ffbfe0 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Thu, 18 Apr 2024 14:07:51 -0700 Subject: [PATCH] Demote launch keyscan exceptions to warnings Similarly to the recently demoted timeouts, these exceptions are not useful since they are internally generated. Log them as warnings without tracebacks. Change-Id: I84c04b65c3006f9173e5880b38694acc368b8f44 --- nodepool/driver/statemachine.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/nodepool/driver/statemachine.py b/nodepool/driver/statemachine.py index fa312abef..bb1c1a2ec 100644 --- a/nodepool/driver/statemachine.py +++ b/nodepool/driver/statemachine.py @@ -254,8 +254,11 @@ class StateMachineNodeLauncher(stats.StatsReporter): dt = int(time.monotonic() - self.nodescan_request.start_time) self.log.debug("Scanned keys in %s", dt) - except Exception: - self.log.exception("Exception scanning keys:") + except Exception as e: + if isinstance(e, exceptions.ConnectionTimeoutException): + self.log.warning("Error scanning keys: %s", str(e)) + else: + self.log.exception("Exception scanning keys:") raise exceptions.LaunchKeyscanException( "Can't scan instance %s key" % node.id) if keys: @@ -322,7 +325,8 @@ class StateMachineNodeLauncher(stats.StatsReporter): self.manager.nodescan_worker.removeRequest(self.nodescan_request) self.nodescan_request = None except Exception as e: - if isinstance(e, exceptions.TimeoutException): + if isinstance(e, (exceptions.TimeoutException, + exceptions.LaunchKeyscanException)): self.log.warning( "Launch attempt %d/%d for node %s, failed: %s", self.attempts, self.retries, node.id, str(e))