dongjoon-hyun opened a new pull request, #60562:
URL: https://github.com/apache/spark/pull/60562

   ### What changes were proposed in this pull request?
   
   This PR aims to wrap each cleanup `delete()` in the failure paths of 
`Client.run()` with `Utils.tryLogNonFatalError`. A failed cleanup is logged, 
`spark-submit` still throws the original exception, and the next cleanup still 
runs.
   
   | Step that fails | Cleanup |
   | --- | --- |
   | Applying the pre-resources | Delete the pre-resources |
   | Creating the driver pod | Delete the pre-resources |
   | Refreshing the owner references of the pre-resources | Delete the driver 
pod, then the pre-resources |
   | Applying the other resources, including the driver `ConfigMap` | Delete 
the driver pod |
   
   ### Why are the changes needed?
   
   Each cleanup `delete()` runs in a `catch` block before `throw e`. If the 
`delete()` throws, its exception replaces the original one. This can happen 
when the API server is unreachable, or when the submitter is not allowed to 
delete the resource (HTTP 403). Then `spark-submit` reports the cleanup failure 
instead of the reason why the submission failed. In addition:
   
   - When the driver pod cannot be created, the `kubectl auth can-i create pod` 
hint is not logged because it comes after the `delete()`.
   - When the owner references of the pre-resources cannot be refreshed, a 
failed driver pod `delete()` skips the deletion of the pre-resources. They may 
not have the owner reference to the driver pod yet, so the Kubernetes garbage 
collector does not delete them either. Pre-resources are the Volcano `PodGroup` 
and the resources from user feature steps 
(`spark.kubernetes.driver.pod.featureSteps`), which can include `Secret`s.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. When a cleanup `delete()` fails after a submission failure, 
`spark-submit` now logs the cleanup failure, continues the remaining cleanup, 
and throws the original exception. Previously, it threw the exception of the 
cleanup `delete()` and skipped the remaining cleanup. The driver pod cleanup 
exists since Apache Spark 2.3.0 (SPARK-22646), and the pre-resource cleanup 
since Apache Spark 3.3.0 (SPARK-37331).
   
   ### How was this patch tested?
   
   Pass the CIs with the newly added test cases in `ClientSuite`. Each test 
case makes the cleanup `delete()` calls fail, then checks that `run()` throws 
the original exception (`thrown eq failure`) and that the next cleanup still 
runs. Without this fix, all four test cases fail.
   
   ```
   $ build/sbt -Pkubernetes 'kubernetes/testOnly *ClientSuite'
   ...
   [info] Tests: succeeded 10, failed 0, canceled 0, ignored 0, pending 0
   [info] All tests passed.
   ```
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: Claude Opus 5.5
   


-- 
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]

Reply via email to