Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class KyuubiOperationKubernetesClusterClusterModeSuite
appMgrInfo,
sessionHandle.identifier.toString)
assert(appInfo.state == RUNNING)
assert(appInfo.name.startsWith(driverPodNamePrefix))
assert(appInfo.podName.exists(_.startsWith(driverPodNamePrefix)))
}

val killResponse = k8sOperation.killApplicationByTag(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,18 @@ 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(
"id" -> id,
"name" -> name,
"state" -> state.toString,
"url" -> url.orNull,
"error" -> error.orNull)
"error" -> error.orNull) ++
podName.map("podName" -> _).toMap
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.orNull, appLabel)
}
info(s"Remove terminated application $removed with ${toLabel(appLabel)}")
}
Expand Down Expand Up @@ -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.name).delete().isEmpty,
deleted,
s"[$kubernetesInfo] Operation of deleted" +
s" application[appId: ${info.id}, ${toLabel(tag)}] is completed")
}
Expand Down Expand Up @@ -411,15 +416,17 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging {
id = getPodAppId(pod),
name = getPodAppName(pod),
state = appState,
error = appError))
error = appError,
podName = Some(pod.getMetadata.getName)))
}.getOrElse {
appInfoStore.put(
kyuubiUniqueKey,
kubernetesInfo -> ApplicationInfo(
id = getPodAppId(pod),
name = getPodAppName(pod),
state = appState,
error = appError))
error = appError,
podName = Some(pod.getMetadata.getName)))
}
}
}
Expand Down Expand Up @@ -466,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 {
Comment thread
turboFei marked this conversation as resolved.
Outdated
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" +
Expand Down