fix(sparkapplication): backfill terminationTime when missing so TTL applies#2926
fix(sparkapplication): backfill terminationTime when missing so TTL applies#2926a7i wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
🎉 Welcome to the Kubeflow Spark Operator! 🎉 Thanks for opening your first PR! We're happy to have you as part of our community 🚀 Here's what happens next:
Join the community:
Feel free to ask questions in the comments if you need any help or clarification! |
There was a problem hiding this comment.
Pull request overview
Backfills missing status.terminationTime for terminal SparkApplication resources so TTL expiry (spec.timeToLiveSeconds) can be computed and garbage-collection can proceed as intended in the SparkApplication controller.
Changes:
- Added
util.EnsureTerminationTimeForTerminalStateto populatestatus.terminationTimewhen missing for terminal apps, preferringstatus.lastSubmissionAttemptTime. - Invoked the helper in
reconcileTerminatedSparkApplicationbefore TTL/expiry checks. - Added unit tests for the new helper.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| pkg/util/sparkapplication.go | Adds helper to backfill terminationTime for terminal apps to enable TTL expiry. |
| internal/controller/sparkapplication/controller.go | Calls the helper before IsExpired/TTL handling in terminated reconcile path. |
| pkg/util/sparkapplication_test.go | Adds tests validating helper behavior for common cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
1c05863 to
ae0d47e
Compare
…pplies Terminal FAILED or COMPLETED apps could omit status.terminationTime, so timeToLiveSeconds never triggered deletion. Reuse lastSubmissionAttemptTime only when the app never started a driver execution (executionAttempts == 0 and submissionAttempts > 0). Otherwise use time.Now() so TTL is not measured from an old submission after a long run. Invoked from reconcileTerminatedSparkApplication before IsExpired. Signed-off-by: Amir Alavi <amiralavi7@gmail.com>
ae0d47e to
b3c120d
Compare
Thanks for raising the PR. I am wondering if this holds for the recent versions of the operator. If you trace the transitions from parent states to Would you be able to confirm more details as to why you see this issue on your end? I believe we can have this code change more so as a defensive posture rather than framing it as a bug fix. |
|
@tariq-hasan we continue to face this issue, but as you suggested, perhaps it's best to fix the root cause. We have this issue on both spark-operator v1 and v2. It seems to happen when the operator restarts and there is a pipeline with completed/succeeded driver pods. |
|
@tariq-hasan tried to take a stab at fixing the root issue here, look forward to your feedback #2934 |
Purpose of this PR
Terminal
SparkApplicationresources (FAILEDorCOMPLETED) sometimes havestatus.terminationTimeunset. Expiry and TTL deletion are based onterminationTime, sotimeToLiveSecondsnever applies and the CR (and related resources) are never garbage-collected.This change backfills
terminationTimewhen the app is already in a terminal state but the field is missing, preferringlastSubmissionAttemptTime(appropriate for submission-time failures).Proposed changes:
EnsureTerminationTimeForTerminalStateinpkg/utiland call it fromreconcileTerminatedSparkApplicationbeforeIsExpired/ TTL handling.Example (redacted manifest excerpt:
spec.timeToLiveSecondsandstatusonly):Change Category
Rationale
reconcileTerminatedSparkApplicationreturns early whenterminationTimeis zero, so TTL requeue andIsExpirednever run. Backfilling fromlastSubmissionAttemptTimealigns the clock with when the run actually stopped for submission failures, and allows overdue TTLs to delete immediately on the next reconcile.Checklist
Additional Notes
Risk: Low
pkg/utiltests were run locally. Controller integration tests require envtest binaries.