HwangDongJun commented on code in PR #58187:
URL: https://github.com/apache/spark/pull/58187#discussion_r4163428383
##########
resource-managers/kubernetes/core/src/main/scala/org/apache/spark/deploy/k8s/submit/KubernetesClientApplication.scala:
##########
@@ -209,6 +293,54 @@ private[spark] class Client(
log"submission ID ${MDC(SUBMISSION_ID, sId)} into Kubernetes")
}
}
+
+ // SPARK-38079: best-effort cleanup for pre-resources (and the driver pod,
if it was created)
+ // that were left without an owner reference because this process was
terminated abruptly
+ // before the owner-reference refresh in run() completed. See the comment
above the shutdown
+ // hook registration in run() for why this window exists and why it must
stop mattering once
+ // that refresh completes.
+ //
+ // package-private (rather than private) so it can be unit-tested directly
-- actually
+ // triggering a JVM shutdown hook from a test is impractical, so tests
instead call this
+ // method directly with injected pre/post-state and a fake
recoveryClientFactory.
+ private[submit] def cleanupOrphanedPreResources(
+ preResources: Seq[HasMetadata],
+ driverPodName: String,
+ preResourcesApplied: Boolean,
+ podCreatedByUs: Boolean): Unit = {
+ if (preResourcesApplied) {
+ try {
+ Utils.tryWithResource(recoveryClientFactory()) { recoveryClient =>
Review Comment:
This hook (and the blocking I/O inside it) is gone, replaced by
`spec.schedulingGates`.
Since there's no shutdown hook registered anymore, there's nothing competing
with Hadoop's shutdown hook timeout or with other hooks like temp directory
deletion:
- A Ctrl-C/SIGTERM during `create()` or `serverSideApply()` now behaves the
same as it did on master before this PR — the process exits immediately, and
whatever pod/pre-resources already exist are left behind (gated, so harmless —
see [the finally/shutdown-hook reply
above](https://github.com/apache/spark/pull/58187#discussion_r4129910495)).
- A second Ctrl-C is never swallowed, since there's no hook blocking
shutdown in the first place.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]