Skip to content

Commit e164d8b

Browse files
authored
Compute status check (#9288)
* fix: Use SUCCESS value instead of name * fix: Use SUCCESS value instead of name * fix: wait for RUNNING status * fix: raise on failed launch
1 parent 370956c commit e164d8b

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

compute/oslogin/oslogin_service_account_ssh_test.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,16 @@ def oslogin_instance(ssh_firewall, oslogin_service_account):
182182
policy.bindings = [binding]
183183
client.set_iam_policy(project=PROJECT, zone=ZONE, resource=TEST_ID, zone_set_policy_request_resource=policy)
184184

185-
# Wait for everything to propagate
186-
time.sleep(5)
185+
for attempt in range(5):
186+
time.sleep(5)
187+
instance = client.get(project=PROJECT, zone=ZONE, instance=instance.name)
188+
if instance.status == "RUNNING":
189+
break
190+
191+
if instance.status != "RUNNING":
192+
raise Exception(f"Unhealthy instance status: {instance.status}")
187193

188-
yield client.get(project=PROJECT, zone=ZONE, instance=instance.name)
194+
yield instance
189195

190196
client.delete(project=PROJECT, zone=ZONE, instance=instance.name).result()
191197

0 commit comments

Comments
 (0)