From 244c96dd986255ba70427b083a5e7479c2c25c5e Mon Sep 17 00:00:00 2001 From: Ahmed Ezzat Date: Mon, 18 Sep 2023 18:49:17 +0300 Subject: [PATCH] Minimise race-conditions --- dask_kubernetes/operator/controller/controller.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dask_kubernetes/operator/controller/controller.py b/dask_kubernetes/operator/controller/controller.py index e798f8edb..68e00d2fb 100644 --- a/dask_kubernetes/operator/controller/controller.py +++ b/dask_kubernetes/operator/controller/controller.py @@ -599,12 +599,14 @@ async def daskworkergroup_replica_update( for worker in current_workers: if len(pending_workers) >= -workers_needed: break - if await worker.ready(): + if not await worker.ready(): pending_workers.append(worker) if pending_workers: logger.info(f"Pending worker deployments to delete: {pending_workers}") for worker in pending_workers: + if await worker.ready(): + continue await worker.delete() n_workers = -workers_needed - len(pending_workers)