From cbb11f5ca364401840da7960a8d9452854a0b873 Mon Sep 17 00:00:00 2001 From: "Wang, Fei" Date: Mon, 28 Oct 2024 12:53:05 -0700 Subject: [PATCH 1/2] shutdown --- .../apache/kyuubi/engine/KubernetesApplicationOperation.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala index 74dc398f05b..f96a06d6512 100644 --- a/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala +++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala @@ -266,6 +266,7 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging { if (cleanupTerminatedAppInfoTrigger != null) { cleanupTerminatedAppInfoTrigger.invalidateAll() + ThreadUtils.shutdown(expireCleanUpTriggerCacheExecutor) cleanupTerminatedAppInfoTrigger = null } From 78c2a6c0ecf67e0056aef613415e113ba5a3a013 Mon Sep 17 00:00:00 2001 From: "Wang, Fei" Date: Mon, 28 Oct 2024 12:58:29 -0700 Subject: [PATCH 2/2] prevent npe --- .../engine/KubernetesApplicationOperation.scala | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala index f96a06d6512..b24fefbb8b6 100644 --- a/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala +++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala @@ -151,6 +151,7 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging { expireCleanUpTriggerCacheExecutor, () => { try { + if (cleanupTerminatedAppInfoTrigger == null) return cleanupTerminatedAppInfoTrigger.asMap().asScala.foreach { case (key, _) => // do get to trigger cache eviction @@ -266,7 +267,6 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging { if (cleanupTerminatedAppInfoTrigger != null) { cleanupTerminatedAppInfoTrigger.invalidateAll() - ThreadUtils.shutdown(expireCleanUpTriggerCacheExecutor) cleanupTerminatedAppInfoTrigger = null } @@ -274,6 +274,16 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging { Utils.tryLogNonFatalError(client.close()) } kubernetesClients.clear() + + if (expireCleanUpTriggerCacheExecutor != null) { + ThreadUtils.shutdown(expireCleanUpTriggerCacheExecutor) + expireCleanUpTriggerCacheExecutor = null + } + + if (cleanupCanceledAppPodExecutor != null) { + ThreadUtils.shutdown(cleanupCanceledAppPodExecutor) + cleanupCanceledAppPodExecutor = null + } } private class SparkEnginePodEventHandler(kubernetesInfo: KubernetesInfo)