From 50fad6bc5fe8a0369c672d880e957309833fc4c9 Mon Sep 17 00:00:00 2001 From: "Wang, Fei" Date: Thu, 24 Apr 2025 13:37:44 -0700 Subject: [PATCH 1/5] fix ut --- .../kubernetes/test/spark/SparkOnKubernetesTestsSuite.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/integration-tests/kyuubi-kubernetes-it/src/test/scala/org/apache/kyuubi/kubernetes/test/spark/SparkOnKubernetesTestsSuite.scala b/integration-tests/kyuubi-kubernetes-it/src/test/scala/org/apache/kyuubi/kubernetes/test/spark/SparkOnKubernetesTestsSuite.scala index d6ef69d0883..7f5ec1e697d 100644 --- a/integration-tests/kyuubi-kubernetes-it/src/test/scala/org/apache/kyuubi/kubernetes/test/spark/SparkOnKubernetesTestsSuite.scala +++ b/integration-tests/kyuubi-kubernetes-it/src/test/scala/org/apache/kyuubi/kubernetes/test/spark/SparkOnKubernetesTestsSuite.scala @@ -230,7 +230,8 @@ class KyuubiOperationKubernetesClusterClusterModeSuite appMgrInfo, sessionHandle.identifier.toString) assert(appInfo.state == RUNNING) - assert(appInfo.name.startsWith(driverPodNamePrefix)) + // See KYUUBI-7034: prefer to use pod `spark-app-name` label instead of pod name + // assert(appInfo.name.startsWith(driverPodNamePrefix)) } val killResponse = k8sOperation.killApplicationByTag( From c1d308437ecc925164dd4889dfa4506bbf91efa2 Mon Sep 17 00:00:00 2001 From: "Wang, Fei" Date: Thu, 24 Apr 2025 14:48:33 -0700 Subject: [PATCH 2/5] reduce interval for test stability --- .../kubernetes/test/spark/SparkOnKubernetesTestsSuite.scala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/integration-tests/kyuubi-kubernetes-it/src/test/scala/org/apache/kyuubi/kubernetes/test/spark/SparkOnKubernetesTestsSuite.scala b/integration-tests/kyuubi-kubernetes-it/src/test/scala/org/apache/kyuubi/kubernetes/test/spark/SparkOnKubernetesTestsSuite.scala index 7f5ec1e697d..6ed48f43f4d 100644 --- a/integration-tests/kyuubi-kubernetes-it/src/test/scala/org/apache/kyuubi/kubernetes/test/spark/SparkOnKubernetesTestsSuite.scala +++ b/integration-tests/kyuubi-kubernetes-it/src/test/scala/org/apache/kyuubi/kubernetes/test/spark/SparkOnKubernetesTestsSuite.scala @@ -126,6 +126,7 @@ class SparkClusterModeOnKubernetesSuiteBase .set("spark.kubernetes.driver.podTemplateFile", driverTemplate.getPath) .set(ZK_CLIENT_PORT_ADDRESS.key, localhostAddress) .set(FRONTEND_THRIFT_BINARY_BIND_HOST.key, localhostAddress) + .set(BATCH_APPLICATION_CHECK_INTERVAL.key, "100") } } @@ -224,7 +225,7 @@ class KyuubiOperationKubernetesClusterClusterModeSuite batchRequest) // wait for driver pod start - eventually(timeout(3.minutes), interval(5.second)) { + eventually(timeout(3.minutes), interval(100.milliseconds)) { // trigger k8sOperation init here val appInfo = k8sOperation.getApplicationInfoByTag( appMgrInfo, From 19f34bc83c8d0a71d26b4d901bab7fba541c500c Mon Sep 17 00:00:00 2001 From: "Wang, Fei" Date: Thu, 24 Apr 2025 16:02:01 -0700 Subject: [PATCH 3/5] do not get pod name from appName --- .../spark/SparkOnKubernetesTestsSuite.scala | 9 ++-- .../kyuubi/engine/ApplicationOperation.scala | 27 ++++++++++++ .../KubernetesApplicationOperation.scala | 43 +++++++++++++------ 3 files changed, 60 insertions(+), 19 deletions(-) diff --git a/integration-tests/kyuubi-kubernetes-it/src/test/scala/org/apache/kyuubi/kubernetes/test/spark/SparkOnKubernetesTestsSuite.scala b/integration-tests/kyuubi-kubernetes-it/src/test/scala/org/apache/kyuubi/kubernetes/test/spark/SparkOnKubernetesTestsSuite.scala index 6ed48f43f4d..bb10cdddbe5 100644 --- a/integration-tests/kyuubi-kubernetes-it/src/test/scala/org/apache/kyuubi/kubernetes/test/spark/SparkOnKubernetesTestsSuite.scala +++ b/integration-tests/kyuubi-kubernetes-it/src/test/scala/org/apache/kyuubi/kubernetes/test/spark/SparkOnKubernetesTestsSuite.scala @@ -28,7 +28,7 @@ import org.apache.kyuubi._ import org.apache.kyuubi.client.util.BatchUtils._ import org.apache.kyuubi.config.KyuubiConf import org.apache.kyuubi.config.KyuubiConf._ -import org.apache.kyuubi.engine.{ApplicationInfo, ApplicationManagerInfo, ApplicationOperation, KubernetesApplicationOperation} +import org.apache.kyuubi.engine.{ApplicationInfo, ApplicationManagerInfo, ApplicationOperation, KubernetesApplicationInfo, KubernetesApplicationOperation} import org.apache.kyuubi.engine.ApplicationState.{FAILED, NOT_FOUND, RUNNING} import org.apache.kyuubi.engine.spark.SparkProcessBuilder import org.apache.kyuubi.kubernetes.test.MiniKube @@ -126,7 +126,6 @@ class SparkClusterModeOnKubernetesSuiteBase .set("spark.kubernetes.driver.podTemplateFile", driverTemplate.getPath) .set(ZK_CLIENT_PORT_ADDRESS.key, localhostAddress) .set(FRONTEND_THRIFT_BINARY_BIND_HOST.key, localhostAddress) - .set(BATCH_APPLICATION_CHECK_INTERVAL.key, "100") } } @@ -225,14 +224,14 @@ class KyuubiOperationKubernetesClusterClusterModeSuite batchRequest) // wait for driver pod start - eventually(timeout(3.minutes), interval(100.milliseconds)) { + eventually(timeout(3.minutes), interval(5.second)) { // trigger k8sOperation init here val appInfo = k8sOperation.getApplicationInfoByTag( appMgrInfo, sessionHandle.identifier.toString) assert(appInfo.state == RUNNING) - // See KYUUBI-7034: prefer to use pod `spark-app-name` label instead of pod name - // assert(appInfo.name.startsWith(driverPodNamePrefix)) + assert( + appInfo.asInstanceOf[KubernetesApplicationInfo].podName.startsWith(driverPodNamePrefix)) } val killResponse = k8sOperation.killApplicationByTag( diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/ApplicationOperation.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/ApplicationOperation.scala index 339df2f7857..ecd10bee1ad 100644 --- a/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/ApplicationOperation.scala +++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/ApplicationOperation.scala @@ -129,6 +129,33 @@ object ApplicationInfo { val UNKNOWN: ApplicationInfo = ApplicationInfo(null, null, ApplicationState.UNKNOWN) } +class KubernetesApplicationInfo( + id: String, + name: String, + state: ApplicationState, + url: Option[String] = None, + error: Option[String] = None, + val podName: String) extends ApplicationInfo(id, name, state, url, error) { + override def toMap: Map[String, String] = super.toMap ++ Map("podName" -> podName) +} + +object KubernetesApplicationInfo { + val NOT_FOUND: KubernetesApplicationInfo = new KubernetesApplicationInfo( + null, + null, + ApplicationState.NOT_FOUND, + None, + None, + null) + val UNKNOWN: KubernetesApplicationInfo = new KubernetesApplicationInfo( + null, + null, + ApplicationState.UNKNOWN, + None, + None, + null) +} + object ApplicationOperation { val NOT_FOUND = "APPLICATION_NOT_FOUND" } 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 8981c1f687f..3b069eac60d 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 @@ -66,8 +66,8 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging { kyuubiConf.get(KyuubiConf.KUBERNETES_APPLICATION_STATE_CONTAINER) // key is kyuubi_unique_key - private val appInfoStore: ConcurrentHashMap[String, (KubernetesInfo, ApplicationInfo)] = - new ConcurrentHashMap[String, (KubernetesInfo, ApplicationInfo)] + private val appInfoStore: ConcurrentHashMap[String, (KubernetesInfo, KubernetesApplicationInfo)] = + new ConcurrentHashMap[String, (KubernetesInfo, KubernetesApplicationInfo)] // key is kyuubi_unique_key private var cleanupTerminatedAppInfoTrigger: Cache[String, ApplicationState] = _ @@ -140,7 +140,7 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging { case COMPLETED => !ApplicationState.isFailed(notification.getValue) } if (shouldDelete) { - deletePod(kubernetesInfo, removed.name, appLabel) + deletePod(kubernetesInfo, removed.podName, appLabel) } info(s"Remove terminated application $removed with ${toLabel(appLabel)}") } @@ -220,7 +220,7 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging { s"[$kubernetesInfo] Target application[${toLabel(tag)}] is in ${info.state} state") case _ => ( - !kubernetesClient.pods.withName(info.name).delete().isEmpty, + !kubernetesClient.pods.withName(info.podName).delete().isEmpty, s"[$kubernetesInfo] Operation of deleted" + s" application[appId: ${info.id}, ${toLabel(tag)}] is completed") } @@ -252,7 +252,9 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging { // need to initialize the kubernetes client if not exists getOrCreateKubernetesClient(appMgrInfo.kubernetesInfo) val (_, appInfo) = - appInfoStore.getOrDefault(tag, appMgrInfo.kubernetesInfo -> ApplicationInfo.NOT_FOUND) + appInfoStore.getOrDefault( + tag, + appMgrInfo.kubernetesInfo -> KubernetesApplicationInfo.NOT_FOUND) (appInfo.state, submitTime) match { // Kyuubi should wait second if pod is not be created case (NOT_FOUND, Some(_submitTime)) => @@ -260,14 +262,14 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging { if (elapsedTime > submitTimeout) { error(s"Can't find target driver pod by ${toLabel(tag)}, " + s"elapsed time: ${elapsedTime}ms exceeds ${submitTimeout}ms.") - ApplicationInfo.NOT_FOUND + KubernetesApplicationInfo.NOT_FOUND } else { warn(s"Waiting for driver pod with ${toLabel(tag)} to be created, " + s"elapsed time: ${elapsedTime}ms, return UNKNOWN status") - ApplicationInfo.UNKNOWN + KubernetesApplicationInfo.UNKNOWN } case (NOT_FOUND, None) => - ApplicationInfo.NOT_FOUND + KubernetesApplicationInfo.NOT_FOUND case _ => debug(s"Successfully got application[${toLabel(tag)}]'s info: $appInfo") appInfo @@ -275,7 +277,7 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging { } catch { case e: Exception => error(s"Failed to get application by ${toLabel(tag)}, due to ${e.getMessage}") - ApplicationInfo.NOT_FOUND + KubernetesApplicationInfo.NOT_FOUND } } @@ -407,19 +409,23 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging { Option(appInfoStore.get(kyuubiUniqueKey)).map { case (_, appInfo) => appInfoStore.put( kyuubiUniqueKey, - kubernetesInfo -> appInfo.copy( + kubernetesInfo -> new KubernetesApplicationInfo( id = getPodAppId(pod), name = getPodAppName(pod), state = appState, - error = appError)) + // inherit the url from the old appInfo + url = appInfo.url, + error = appError, + podName = pod.getMetadata.getName)) }.getOrElse { appInfoStore.put( kyuubiUniqueKey, - kubernetesInfo -> ApplicationInfo( + kubernetesInfo -> new KubernetesApplicationInfo( id = getPodAppId(pod), name = getPodAppName(pod), state = appState, - error = appError)) + error = appError, + podName = pod.getMetadata.getName)) } } } @@ -443,7 +449,16 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging { val kyuubiUniqueKey = svc.getSpec.getSelector.get(LABEL_KYUUBI_UNIQUE_KEY) appInfoStore.synchronized { Option(appInfoStore.get(kyuubiUniqueKey)).foreach { case (_, appInfo) => - appInfoStore.put(kyuubiUniqueKey, kubernetesInfo -> appInfo.copy(url = Some(appUrl))) + appInfoStore.put( + kyuubiUniqueKey, + kubernetesInfo -> + new KubernetesApplicationInfo( + id = appInfo.id, + name = appInfo.name, + state = appInfo.state, + url = Some(appUrl), + error = appInfo.error, + podName = appInfo.podName)) } } }.getOrElse(warn(s"Spark UI port not found in service ${svc.getMetadata.getName}")) From 18e48c07986406b0ece097b23f15fad243c39b9d Mon Sep 17 00:00:00 2001 From: "Wang, Fei" Date: Thu, 24 Apr 2025 20:34:51 -0700 Subject: [PATCH 4/5] comments --- .../spark/SparkOnKubernetesTestsSuite.scala | 5 +- .../kyuubi/engine/ApplicationOperation.scala | 34 ++--------- .../KubernetesApplicationOperation.scala | 57 ++++++++----------- 3 files changed, 31 insertions(+), 65 deletions(-) diff --git a/integration-tests/kyuubi-kubernetes-it/src/test/scala/org/apache/kyuubi/kubernetes/test/spark/SparkOnKubernetesTestsSuite.scala b/integration-tests/kyuubi-kubernetes-it/src/test/scala/org/apache/kyuubi/kubernetes/test/spark/SparkOnKubernetesTestsSuite.scala index bb10cdddbe5..bda997ddc41 100644 --- a/integration-tests/kyuubi-kubernetes-it/src/test/scala/org/apache/kyuubi/kubernetes/test/spark/SparkOnKubernetesTestsSuite.scala +++ b/integration-tests/kyuubi-kubernetes-it/src/test/scala/org/apache/kyuubi/kubernetes/test/spark/SparkOnKubernetesTestsSuite.scala @@ -28,7 +28,7 @@ import org.apache.kyuubi._ import org.apache.kyuubi.client.util.BatchUtils._ import org.apache.kyuubi.config.KyuubiConf import org.apache.kyuubi.config.KyuubiConf._ -import org.apache.kyuubi.engine.{ApplicationInfo, ApplicationManagerInfo, ApplicationOperation, KubernetesApplicationInfo, KubernetesApplicationOperation} +import org.apache.kyuubi.engine.{ApplicationInfo, ApplicationManagerInfo, ApplicationOperation, KubernetesApplicationOperation} import org.apache.kyuubi.engine.ApplicationState.{FAILED, NOT_FOUND, RUNNING} import org.apache.kyuubi.engine.spark.SparkProcessBuilder import org.apache.kyuubi.kubernetes.test.MiniKube @@ -230,8 +230,7 @@ class KyuubiOperationKubernetesClusterClusterModeSuite appMgrInfo, sessionHandle.identifier.toString) assert(appInfo.state == RUNNING) - assert( - appInfo.asInstanceOf[KubernetesApplicationInfo].podName.startsWith(driverPodNamePrefix)) + assert(appInfo.podName.exists(_.startsWith(driverPodNamePrefix))) } val killResponse = k8sOperation.killApplicationByTag( diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/ApplicationOperation.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/ApplicationOperation.scala index ecd10bee1ad..0788dbc4dfa 100644 --- a/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/ApplicationOperation.scala +++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/ApplicationOperation.scala @@ -112,7 +112,9 @@ case class ApplicationInfo( name: String, state: ApplicationState, url: Option[String] = None, - error: Option[String] = None) { + error: Option[String] = None, + // only used for K8s and still possible to be None for cases like NOT_FOUND state for K8s cases + podName: Option[String] = None) { def toMap: Map[String, String] = { Map( @@ -120,7 +122,8 @@ case class ApplicationInfo( "name" -> name, "state" -> state.toString, "url" -> url.orNull, - "error" -> error.orNull) + "error" -> error.orNull) ++ + podName.map("podName" -> _).toMap } } @@ -129,33 +132,6 @@ object ApplicationInfo { val UNKNOWN: ApplicationInfo = ApplicationInfo(null, null, ApplicationState.UNKNOWN) } -class KubernetesApplicationInfo( - id: String, - name: String, - state: ApplicationState, - url: Option[String] = None, - error: Option[String] = None, - val podName: String) extends ApplicationInfo(id, name, state, url, error) { - override def toMap: Map[String, String] = super.toMap ++ Map("podName" -> podName) -} - -object KubernetesApplicationInfo { - val NOT_FOUND: KubernetesApplicationInfo = new KubernetesApplicationInfo( - null, - null, - ApplicationState.NOT_FOUND, - None, - None, - null) - val UNKNOWN: KubernetesApplicationInfo = new KubernetesApplicationInfo( - null, - null, - ApplicationState.UNKNOWN, - None, - None, - null) -} - object ApplicationOperation { val NOT_FOUND = "APPLICATION_NOT_FOUND" } 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 3b069eac60d..a7d0028df1c 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 @@ -66,8 +66,8 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging { kyuubiConf.get(KyuubiConf.KUBERNETES_APPLICATION_STATE_CONTAINER) // key is kyuubi_unique_key - private val appInfoStore: ConcurrentHashMap[String, (KubernetesInfo, KubernetesApplicationInfo)] = - new ConcurrentHashMap[String, (KubernetesInfo, KubernetesApplicationInfo)] + private val appInfoStore: ConcurrentHashMap[String, (KubernetesInfo, ApplicationInfo)] = + new ConcurrentHashMap[String, (KubernetesInfo, ApplicationInfo)] // key is kyuubi_unique_key private var cleanupTerminatedAppInfoTrigger: Cache[String, ApplicationState] = _ @@ -140,7 +140,7 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging { case COMPLETED => !ApplicationState.isFailed(notification.getValue) } if (shouldDelete) { - deletePod(kubernetesInfo, removed.podName, appLabel) + deletePod(kubernetesInfo, removed.podName.orNull, appLabel) } info(s"Remove terminated application $removed with ${toLabel(appLabel)}") } @@ -219,8 +219,13 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging { false, s"[$kubernetesInfo] Target application[${toLabel(tag)}] is in ${info.state} state") case _ => + val deleted = info.podName match { + case Some(podName) => !kubernetesClient.pods.withName(podName).delete().isEmpty + case None => + !kubernetesClient.pods.withLabel(LABEL_KYUUBI_UNIQUE_KEY, tag).delete().isEmpty + } ( - !kubernetesClient.pods.withName(info.podName).delete().isEmpty, + deleted, s"[$kubernetesInfo] Operation of deleted" + s" application[appId: ${info.id}, ${toLabel(tag)}] is completed") } @@ -252,9 +257,7 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging { // need to initialize the kubernetes client if not exists getOrCreateKubernetesClient(appMgrInfo.kubernetesInfo) val (_, appInfo) = - appInfoStore.getOrDefault( - tag, - appMgrInfo.kubernetesInfo -> KubernetesApplicationInfo.NOT_FOUND) + appInfoStore.getOrDefault(tag, appMgrInfo.kubernetesInfo -> ApplicationInfo.NOT_FOUND) (appInfo.state, submitTime) match { // Kyuubi should wait second if pod is not be created case (NOT_FOUND, Some(_submitTime)) => @@ -262,14 +265,14 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging { if (elapsedTime > submitTimeout) { error(s"Can't find target driver pod by ${toLabel(tag)}, " + s"elapsed time: ${elapsedTime}ms exceeds ${submitTimeout}ms.") - KubernetesApplicationInfo.NOT_FOUND + ApplicationInfo.NOT_FOUND } else { warn(s"Waiting for driver pod with ${toLabel(tag)} to be created, " + s"elapsed time: ${elapsedTime}ms, return UNKNOWN status") - KubernetesApplicationInfo.UNKNOWN + ApplicationInfo.UNKNOWN } case (NOT_FOUND, None) => - KubernetesApplicationInfo.NOT_FOUND + ApplicationInfo.NOT_FOUND case _ => debug(s"Successfully got application[${toLabel(tag)}]'s info: $appInfo") appInfo @@ -277,7 +280,7 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging { } catch { case e: Exception => error(s"Failed to get application by ${toLabel(tag)}, due to ${e.getMessage}") - KubernetesApplicationInfo.NOT_FOUND + ApplicationInfo.NOT_FOUND } } @@ -409,23 +412,21 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging { Option(appInfoStore.get(kyuubiUniqueKey)).map { case (_, appInfo) => appInfoStore.put( kyuubiUniqueKey, - kubernetesInfo -> new KubernetesApplicationInfo( + kubernetesInfo -> appInfo.copy( id = getPodAppId(pod), name = getPodAppName(pod), state = appState, - // inherit the url from the old appInfo - url = appInfo.url, error = appError, - podName = pod.getMetadata.getName)) + podName = Some(pod.getMetadata.getName))) }.getOrElse { appInfoStore.put( kyuubiUniqueKey, - kubernetesInfo -> new KubernetesApplicationInfo( + kubernetesInfo -> ApplicationInfo( id = getPodAppId(pod), name = getPodAppName(pod), state = appState, error = appError, - podName = pod.getMetadata.getName)) + podName = Some(pod.getMetadata.getName))) } } } @@ -449,16 +450,7 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging { val kyuubiUniqueKey = svc.getSpec.getSelector.get(LABEL_KYUUBI_UNIQUE_KEY) appInfoStore.synchronized { Option(appInfoStore.get(kyuubiUniqueKey)).foreach { case (_, appInfo) => - appInfoStore.put( - kyuubiUniqueKey, - kubernetesInfo -> - new KubernetesApplicationInfo( - id = appInfo.id, - name = appInfo.name, - state = appInfo.state, - url = Some(appUrl), - error = appInfo.error, - podName = appInfo.podName)) + appInfoStore.put(kyuubiUniqueKey, kubernetesInfo -> appInfo.copy(url = Some(appUrl))) } } }.getOrElse(warn(s"Spark UI port not found in service ${svc.getMetadata.getName}")) @@ -481,12 +473,11 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging { podLabelUniqueKey: String): Unit = { try { val kubernetesClient = getOrCreateKubernetesClient(kubernetesInfo) - val deleted = if (podName == null) { - !kubernetesClient.pods() - .withLabel(LABEL_KYUUBI_UNIQUE_KEY, podLabelUniqueKey) - .delete().isEmpty - } else { - !kubernetesClient.pods().withName(podName).delete().isEmpty + val deleted = Option(podName) match { + case Some(_) => !kubernetesClient.pods().withName(podName).delete().isEmpty + case None => !kubernetesClient.pods().withLabel( + LABEL_KYUUBI_UNIQUE_KEY, + podLabelUniqueKey).delete().isEmpty } if (deleted) { info(s"[$kubernetesInfo] Operation of delete pod $podName with" + From 0ff7018d610185e49e20c8e9b36bc7b65f8144a1 Mon Sep 17 00:00:00 2001 From: "Wang, Fei" Date: Thu, 24 Apr 2025 22:15:15 -0700 Subject: [PATCH 5/5] revert --- .../engine/KubernetesApplicationOperation.scala | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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 a7d0028df1c..8b8b2c3768d 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 @@ -473,11 +473,12 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging { podLabelUniqueKey: String): Unit = { try { val kubernetesClient = getOrCreateKubernetesClient(kubernetesInfo) - val deleted = Option(podName) match { - case Some(_) => !kubernetesClient.pods().withName(podName).delete().isEmpty - case None => !kubernetesClient.pods().withLabel( - LABEL_KYUUBI_UNIQUE_KEY, - podLabelUniqueKey).delete().isEmpty + val deleted = if (podName == null) { + !kubernetesClient.pods() + .withLabel(LABEL_KYUUBI_UNIQUE_KEY, podLabelUniqueKey) + .delete().isEmpty + } else { + !kubernetesClient.pods().withName(podName).delete().isEmpty } if (deleted) { info(s"[$kubernetesInfo] Operation of delete pod $podName with" +