This is an automated email from the ASF dual-hosted git repository.
feiwang pushed a commit to branch branch-1.8
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/branch-1.8 by this push:
new 3117046f2 [KYUUBI #5714][FOLLOWUP] Fix NPE when deleting terminated
application pod
3117046f2 is described below
commit 3117046f2a347169a681ad54c0894f7d9036024d
Author: fwang12 <[email protected]>
AuthorDate: Fri Nov 17 14:41:33 2023 +0800
[KYUUBI #5714][FOLLOWUP] Fix NPE when deleting terminated application pod
# :mag: Description
#5714 followup to prevent NPE when deleting pod.
## Issue References ๐
This pull request fixes #
## Describe Your Solution ๐ง
Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context. List any dependencies that are
required for this change.
## Types of changes :bookmark:
- [x] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
## Test Plan ๐งช
#### Behavior Without This Pull Request :coffin:
#### Behavior With This Pull Request :tada:
#### Related Unit Tests
---
# Checklists
## ๐ Author Self Checklist
- [x] My code follows the [style
guidelines](https://kyuubi.readthedocs.io/en/master/contributing/code/style.html)
of this project
- [ ] I have performed a self-review
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature
works
- [ ] New and existing unit tests pass locally with my changes
- [ ] This patch was not authored or co-authored using [Generative
Tooling](https://www.apache.org/legal/generative-tooling.html)
## ๐ Committer Pre-Merge Checklist
- [x] Pull request title is okay.
- [ ] No license issues.
- [ ] Milestone correctly set?
- [ ] Test coverage is ok
- [ ] Assignees are selected.
- [ ] Minimum number of approvals
- [ ] No changes are requested
**Be nice. Be informative.**
Closes #5718 from turboFei/npe_fix.
Closes #5714
74349a361 [fwang12] nit
7093ed8d3 [Cheng Pan] Update
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala
558381ed2 [fwang12] fix npe
454be88d1 [fwang12] prevent npe
Lead-authored-by: fwang12 <[email protected]>
Co-authored-by: Cheng Pan <[email protected]>
Signed-off-by: fwang12 <[email protected]>
(cherry picked from commit d4fa6fdc723d01b34b5790b6f2058a5386da5de0)
Signed-off-by: fwang12 <[email protected]>
---
.../engine/KubernetesApplicationOperation.scala | 24 ++++++++++++++--------
1 file changed, 15 insertions(+), 9 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 a78dd8eb6..dcdadf983 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
@@ -105,25 +105,31 @@ class KubernetesApplicationOperation extends
ApplicationOperation with Logging {
.expireAfterWrite(retainPeriod, TimeUnit.MILLISECONDS)
.removalListener((notification: RemovalNotification[String,
ApplicationState]) => {
Option(appInfoStore.remove(notification.getKey)).foreach { case
(kubernetesInfo, removed) =>
+ val appLabel = notification.getKey
if (deleteSparkDriverPodOnTermination) {
+ val podName = removed.name
try {
val kubernetesClient =
getOrCreateKubernetesClient(kubernetesInfo)
- if
(!kubernetesClient.pods().withName(removed.name).delete().isEmpty) {
- info(s"[$kubernetesInfo] Operation of delete pod
${removed.name} with" +
- s" ${toLabel(notification.getKey)} is completed.")
+ val deleted = if (podName == null) {
+ !kubernetesClient.pods()
+ .withLabel(LABEL_KYUUBI_UNIQUE_KEY, appLabel)
+ .delete().isEmpty
} else {
- warn(s"[$kubernetesInfo] Failed to delete pod ${removed.name}
with" +
- s" ${toLabel(notification.getKey)}.")
+ !kubernetesClient.pods().withName(podName).delete().isEmpty
+ }
+ if (deleted) {
+ info(s"[$kubernetesInfo] Operation of delete pod $podName
with" +
+ s" ${toLabel(appLabel)} is completed.")
+ } else {
+ warn(s"[$kubernetesInfo] Failed to delete pod $podName with
${toLabel(appLabel)}.")
}
} catch {
case NonFatal(e) => error(
- s"[$kubernetesInfo] Failed to delete pod ${removed.name}
with" +
- s" ${toLabel(notification.getKey)}",
+ s"[$kubernetesInfo] Failed to delete pod $podName with
${toLabel(appLabel)}",
e)
}
}
- info(s"Remove terminated application ${removed.id} with " +
- s"[${toLabel(notification.getKey)}, state: ${removed.state}]")
+ info(s"Remove terminated application $removed with
${toLabel(appLabel)}")
}
})
.build()