Skip to content

Commit 78499cb

Browse files
Skip Job cluster creation if already exists (#941)
* Skip Job cluster creation if already exists * Bump pre-commit action
1 parent c544fff commit 78499cb

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

.github/workflows/lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ jobs:
1111
python-version: "3.10"
1212
- name: Install deps
1313
run: ./ci/install-deps.sh
14-
- uses: pre-commit/action@v2.0.0
14+
- uses: pre-commit/action@v3.0.1

dask_kubernetes/operator/controller/controller.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -781,10 +781,11 @@ async def daskjob_create_components(
781781
)
782782
kopf.adopt(cluster_spec)
783783
cluster = await DaskCluster(cluster_spec, namespace=namespace)
784-
await cluster.create()
785-
logger.info(
786-
f"Cluster {cluster_spec['metadata']['name']} for job {name} created in {namespace}."
787-
)
784+
if not await cluster.exists():
785+
await cluster.create()
786+
logger.info(
787+
f"Cluster {cluster_spec['metadata']['name']} for job {name} created in {namespace}."
788+
)
788789

789790
labels = _get_labels(meta)
790791
annotations = _get_annotations(meta)
@@ -804,7 +805,8 @@ async def daskjob_create_components(
804805
)
805806
kopf.adopt(job_pod_spec)
806807
job_pod = await Pod(job_pod_spec, namespace=namespace)
807-
await job_pod.create()
808+
if not await job_pod.exists():
809+
await job_pod.create()
808810
patch.status["clusterName"] = cluster_name
809811
patch.status["jobStatus"] = "ClusterCreated"
810812
patch.status["jobRunnerPodName"] = get_job_runner_pod_name(name)

0 commit comments

Comments
 (0)