Skip to content

Commit

Permalink
[KYUUBI #5237] ConfigMaps deletion on Kubernetes
Browse files Browse the repository at this point in the history
  • Loading branch information
Madhukar525722 committed Sep 17, 2024
1 parent 8e2b1b3 commit 340c3d7
Showing 1 changed file with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,39 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging {
appStateSource,
appStateContainer)
}

try {
val volumes = pod.getSpec.getVolumes.asScala
val configMapVolume = volumes.find(_.getConfigMap != null)
.map(_.getConfigMap.getName)
.find(_.contains("spark-exec"))

configMapVolume match {
case Some(configMapName) =>
val kubernetesClient = getOrCreateKubernetesClient(kubernetesInfo)
val statusDetailsList = kubernetesClient.configMaps().withName(configMapName).delete()

val deletionSuccessful =
statusDetailsList != null && statusDetailsList.asScala.nonEmpty
if (deletionSuccessful) {
info(
s"[$kubernetesInfo] ConfigMap $configMapName associated with " +
s"pod ${pod.getMetadata.getName} deleted successfully.")
} else {
warn(
s"[$kubernetesInfo] Failed to delete ConfigMap $configMapName associated with " +
s"pod ${pod.getMetadata.getName}.")
}
case None =>
warn(
s"[$kubernetesInfo] No ConfigMap volume found for pod ${pod.getMetadata.getName}.")
}
} catch {
case NonFatal(e) => error(
s"[$kubernetesInfo] Failed to delete ConfigMap associated with " +
s"pod ${pod.getMetadata.getName}",
e)
}
}
}

Expand Down

0 comments on commit 340c3d7

Please sign in to comment.