From 156e9e4686417ffc5e45e6533c8b1fd370dbdfce Mon Sep 17 00:00:00 2001 From: Ahmed Ezzat Date: Mon, 18 Sep 2023 23:36:19 +0300 Subject: [PATCH] Missing await --- .../operator/controller/controller.py | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/dask_kubernetes/operator/controller/controller.py b/dask_kubernetes/operator/controller/controller.py index 505c241e8..f4ab48509 100644 --- a/dask_kubernetes/operator/controller/controller.py +++ b/dask_kubernetes/operator/controller/controller.py @@ -606,30 +606,26 @@ async def daskworkergroup_replica_update( ) logger.info(f"Scaled worker group {name} up to {desired_workers} workers.") if workers_needed < 0: - deleted_pending_workers = [] len_current_workers = len(current_workers) - + deleted_workers = [] for idx in range(-workers_needed): if idx > len_current_workers: break worker = current_workers[idx] - kube_pods = worker.pods() + kube_pods = await worker.pods() assert ( len(kube_pods) <= 1 ), "Deployment cannot have more than 1 replica pod" worker_pod = kube_pods[0] - if ( - isinstance(worker_pod.status.phase, str) - and worker_pod.status.phase.lower() == "pending" - ): + if worker_pod.status.phase.lower() == "pending": await worker.delete() - deleted_pending_workers.append(worker_pod.name) + deleted_workers.append(worker_pod.name) - if deleted_pending_workers: - logger.info(f"Deleted pending workers: {deleted_pending_workers}") + if deleted_workers: + logger.info(f"Deleted pending workers: {deleted_workers}") - n_workers = -workers_needed - len(deleted_pending_workers) + n_workers = -workers_needed - len(deleted_workers) if n_workers > 0: worker_ids = await retire_workers( n_workers=n_workers,