Skip to content

Commit

Permalink
Update retire_workers to use kr8s (#767)
Browse files Browse the repository at this point in the history
* Release 2023.7.1

* Update retire_workers to use kr8s
  • Loading branch information
jacobtomlinson committed Jul 14, 2023
1 parent 649ada5 commit 3defed7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions dask_kubernetes/operator/controller/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import aiohttp
import kopf
import kr8s
from kr8s.asyncio.objects import Pod
import kubernetes_asyncio as kubernetes
from importlib_metadata import entry_points
Expand Down Expand Up @@ -465,13 +466,12 @@ async def retire_workers(
logger.debug(
f"Scaling {worker_group_name} failed via the Dask RPC, falling back to LIFO scaling"
)
async with kubernetes.client.api_client.ApiClient() as api_client:
api = kubernetes.client.CoreV1Api(api_client)
workers = await api.list_namespaced_pod(
namespace=namespace,
label_selector=f"dask.org/workergroup-name={worker_group_name}",
)
return [w["metadata"]["name"] for w in workers.items[:-n_workers]]
workers = await kr8s.asyncio.get(
"pods",
namespace=namespace,
label_selector={"dask.org/workergroup-name": worker_group_name},
)
return [w.name for w in workers[:-n_workers]]


async def check_scheduler_idle(scheduler_service_name, namespace, logger):
Expand Down

0 comments on commit 3defed7

Please sign in to comment.