Skip to content

Commit 384eedb

Browse files
leahecoleengelke
andauthored
add check for existing cluster (GoogleCloudPlatform#9784)
Co-authored-by: Charles Engelke <[email protected]>
1 parent 62fc6bb commit 384eedb

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

dataproc/snippets/submit_job_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import uuid
1717

1818
import backoff
19-
from google.api_core.exceptions import (InternalServerError, NotFound,
19+
from google.api_core.exceptions import (AlreadyExists, InternalServerError, NotFound,
2020
ServiceUnavailable)
2121
from google.cloud import dataproc_v1 as dataproc
2222
import pytest
@@ -78,6 +78,9 @@ def cluster_name(cluster_client):
7878
try:
7979
setup_cluster(cluster_client, curr_cluster_name)
8080
yield curr_cluster_name
81+
except AlreadyExists: # 409 can happen when we backoff on service errors during submission
82+
print("Already exists, skipping cluster creation")
83+
yield curr_cluster_name
8184
finally:
8285
teardown_cluster(cluster_client, curr_cluster_name)
8386

0 commit comments

Comments
 (0)