From 8a20be32ae2c1bd2cc920849dfc58ac6e4aa80d6 Mon Sep 17 00:00:00 2001 From: Siyuan Date: Fri, 27 Oct 2023 17:19:52 -0700 Subject: [PATCH] wait for instance starting --- sky/provision/gcp/instance.py | 11 +++++++++++ sky/provision/gcp/instance_utils.py | 3 +-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/sky/provision/gcp/instance.py b/sky/provision/gcp/instance.py index c216b66dfe0a..ae25d8ddca1d 100644 --- a/sky/provision/gcp/instance.py +++ b/sky/provision/gcp/instance.py @@ -254,6 +254,17 @@ def get_order_key(node): # are started correctly. created_instance_ids = [instance_id for success, instance_id in results] + while True: + # wait until all instances are running + instances = resource.filter( + project_id=project_id, + zone=availability_zone, + label_filters=filter_labels, + status_filters=PENDING_STATUS, + ) + if not instances: + break + return common.ProvisionRecord(provider_name='gcp', region=region, zone=availability_zone, diff --git a/sky/provision/gcp/instance_utils.py b/sky/provision/gcp/instance_utils.py index 32b17229c513..ffa4d0afe83e 100644 --- a/sky/provision/gcp/instance_utils.py +++ b/sky/provision/gcp/instance_utils.py @@ -969,8 +969,7 @@ def set_labels(cls, labels: dict, wait_for_operation: bool = True) -> dict: node = cls.load_resource().projects().locations().nodes().get( - name=node_id, - ) + name=node_id) body = { "labels": dict(node["labels"], **labels), }