Skip to content

Commit

Permalink
Set a default value on idleTimeout (#884)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtomlinson authored Apr 19, 2024
1 parent 67a45e9 commit 7326d3c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dask_kubernetes/operator/controller/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,8 @@ async def daskautoscaler_adapt(spec, name, namespace, logger, **kwargs):

@kopf.timer("daskcluster.kubernetes.dask.org", interval=5.0)
async def daskcluster_autoshutdown(spec, name, namespace, logger, **kwargs):
if spec["idleTimeout"]:
idle_timeout = spec.get("idleTimeout", 0)
if idle_timeout:
try:
idle_since = await check_scheduler_idle(
scheduler_service_name=f"{name}-scheduler",
Expand All @@ -861,6 +862,6 @@ async def daskcluster_autoshutdown(spec, name, namespace, logger, **kwargs):
except Exception:
logger.warn("Unable to connect to scheduler, skipping autoshutdown check.")
return
if idle_since and time.time() > idle_since + spec["idleTimeout"]:
if idle_since and time.time() > idle_since + idle_timeout:
cluster = await DaskCluster.get(name, namespace=namespace)
await cluster.delete()

0 comments on commit 7326d3c

Please sign in to comment.