From 7aa459911485ad7fbb1f9ec5bc90d79968c71873 Mon Sep 17 00:00:00 2001 From: Jacob Tomlinson Date: Fri, 19 Apr 2024 10:44:15 +0100 Subject: [PATCH] Set a default value on idleTimeout --- dask_kubernetes/operator/controller/controller.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dask_kubernetes/operator/controller/controller.py b/dask_kubernetes/operator/controller/controller.py index 6cd990e4..07f33cbd 100644 --- a/dask_kubernetes/operator/controller/controller.py +++ b/dask_kubernetes/operator/controller/controller.py @@ -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", @@ -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()