From f0da7ca423273fd45d6025f83e9f61801d89fdc2 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Wed, 2 Jul 2025 19:43:56 -0700 Subject: [PATCH] GCE: catch 404 errors on delete If we try to delete an instance that doesn't exist, GCE will return a 404 which raises an exception. Suppress that so we can continue the process. Change-Id: I692b7268f4fc7104838cc70971f76f6aa837654c --- nodepool/driver/gce/adapter.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nodepool/driver/gce/adapter.py b/nodepool/driver/gce/adapter.py index 52084a733..461de30e6 100644 --- a/nodepool/driver/gce/adapter.py +++ b/nodepool/driver/gce/adapter.py @@ -23,7 +23,7 @@ from nodepool.driver.utils import QuotaInformation, RateLimiter from nodepool import exceptions import googleapiclient.discovery - +import googleapiclient.errors CACHE_TTL = 10 @@ -252,7 +252,11 @@ class GceAdapter(statemachine.Adapter): zone=self.provider.zone, instance=server_id) with self.rate_limiter: - q.execute() + try: + q.execute() + except googleapiclient.errors.HttpError as e: + if e.resp.status != 404: + raise @cachetools.func.ttl_cache(maxsize=1, ttl=CACHE_TTL) def _listInstances(self):