[K8s] Rename checkPodAppCanceled to cleanupOrphanPodIfBatchTerminated and improve orphan pod log messages - #7620
Open
turboFei wants to merge 5 commits into
Open
[K8s] Rename checkPodAppCanceled to cleanupOrphanPodIfBatchTerminated and improve orphan pod log messages#7620turboFei wants to merge 5 commits into
turboFei wants to merge 5 commits into
Conversation
Rename `checkPodAppCanceled` to `cleanupOrphanPodIfBatchTerminated` to
accurately reflect that both the CANCELED path and the submit-timeout
ERROR+NOT_FOUND path result in orphan pods that need cleanup.
Improve log messages to:
- Lead with "Found orphan pod" so the subject is the pod being deleted
- State the action directly ("deleting it") rather than hedging ("try to delete")
- Make the submit-timeout branch explicit about the causal chain
(submit timeout elapsed → app state recorded as NOT_FOUND → pod arrived late)
Keep the original log messages as-is; only the method rename from checkPodAppCanceled to cleanupOrphanPodIfBatchTerminated is intended.
Clarify that the ERROR+NOT_FOUND branch is triggered by submit timeout, and that the pod being deleted is an orphan.
There was a problem hiding this comment.
Pull request overview
This PR updates Kyuubi’s Kubernetes engine pod event handling to better reflect (via naming and logs) the intent to clean up pods that become orphaned when a batch session has already terminated.
Changes:
- Renames
checkPodAppCanceledtocleanupOrphanPodIfBatchTerminatedand updates call sites. - Adds an additional orphan-pod cleanup condition for
ERROR+appState=NOT_FOUND(submit-timeout scenario). - Adjusts orphan-pod warning logs (partially) to be more descriptive.
Suppressed comments (2)
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala:589
- The CANCELED-branch log message still doesn’t identify the pod as an orphan or state the delete action directly, which conflicts with the PR description’s stated logging improvements. Consider making the message explicit (orphan + deleting).
warn(s"[$kubernetesInfo] Batch[$kyuubiUniqueKey] is canceled, " +
s"try to delete the pod ${pod.getMetadata.getName}")
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala:595
- This new
ERROR+appState=NOT_FOUNDbranch changes behavior by deleting pods that previously would not be cleaned up by this code path. The PR description says there is “No behavior change” and that existing tests cover this branch, but there doesn’t appear to be any unit test exercising orphan-pod deletion inKubernetesApplicationOperationSuite(it currently only covers URL building and container-state mapping). Either adjust the PR description to reflect the behavior change and add a focused test for this branch, or move the behavior change to a separate PR.
} else if (batchState.exists(_ == OperationState.ERROR) &&
batch.flatMap(_.appState).exists(_ == ApplicationState.NOT_FOUND)) {
warn(s"[$kubernetesInfo] Batch[$kyuubiUniqueKey] failed due to submit timeout" +
s" (app state: NOT_FOUND), try to delete the orphan pod ${pod.getMetadata.getName}")
deletePod(kubernetesInfo, pod.getMetadata.getName, kyuubiUniqueKey)
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why are the changes needed?
checkPodAppCanceledwas misleading: the method handles two distinct orphan-pod scenarios:kyuubi.engine.kubernetes.submit.timeoutelapsed, Kyuubi recorded app state asNOT_FOUNDand marked the batch FAILED, but the pod started up afterwards.In both cases the pod is orphaned (no owning session), and the old name only hinted at case 1.
Log messages were also vague ("try to delete the pod", "is in error state and application not found") — they didn't identify the pod as an orphan or state the delete action directly.
How was this patch tested?
The ERROR+NOT_FOUND branch (submit-timeout orphan pod cleanup) is a behavior change:
pods that previously went uncleared when a batch failed due to submit timeout will now
be deleted when the informer observes them. The rename and log changes are non-behavioral.
Manual verification: confirmed the orphan-pod cleanup path is triggered correctly
under the CANCELED and submit-timeout ERROR scenarios.
Was this patch authored or co-authored using generative AI tooling?
Assisted-by: Claude:claude-sonnet-4-6