Skip to content

Commit

Permalink
Missing await
Browse files Browse the repository at this point in the history
  • Loading branch information
BitTheByte committed Sep 18, 2023
1 parent a942d34 commit 156e9e4
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions dask_kubernetes/operator/controller/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 156e9e4

Please sign in to comment.