From 4ed2b616299f55976241125b2fa9a608bb2d9d74 Mon Sep 17 00:00:00 2001 From: Alberto Contreras Date: Fri, 11 Oct 2024 14:51:20 +0200 Subject: [PATCH] fix(gce): fix how gce checks for an operation done (#440) Previous implementation relied on the __repr__ or __str__ representation of an internal google sdk enum, which, under some versions of the sdk is `Status.DONE` and under others is an integer. Running cloud-init integration tests with Python 3.12.3 raises: E pycloudlib.errors.PycloudlibError: Expected DONE state, but found 2104194 after waiting 300 seconds. Check GCE console for more details. Use the enum variant DONE for proper comparison. Both, ZoneOperationsClient[0] and GlobalOperationsClient[1]'s get method return an instance of Operation[2] which has an instance of Status[3] as status property. Refs: [0] https://cloud.google.com/python/docs/reference/compute/1.11.0/google.cloud.compute_v1.services.zone_operations.ZoneOperationsClient#google_cloud_compute_v1_services_zone_operations_ZoneOperationsClient_get [1] https://cloud.google.com/python/docs/reference/compute/1.11.0/google.cloud.compute_v1.services.global_operations.GlobalOperationsClient#google_cloud_compute_v1_services_global_operations_GlobalOperationsClient_get [2] https://cloud.google.com/python/docs/reference/compute/1.11.0/google.cloud.compute_v1.types.operation [3] https://cloud.google.com/python/docs/reference/compute/1.11.0/google.cloud.compute_v1.types.Operation.Status --- VERSION | 2 +- pycloudlib/gce/cloud.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index a77b16de..3202829c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1!10.0.3 +1!10.0.4 diff --git a/pycloudlib/gce/cloud.py b/pycloudlib/gce/cloud.py index a7be3619..a56f988f 100644 --- a/pycloudlib/gce/cloud.py +++ b/pycloudlib/gce/cloud.py @@ -542,7 +542,7 @@ def _wait_for_operation( except GoogleAPICallError as e: raise_on_error(e) else: - if str(response.status) == "Status.DONE": + if response.status == compute_v1.types.Operation.Status.DONE: break time.sleep(1) else: