jiangzho opened a new pull request, #711:
URL: https://github.com/apache/spark-kubernetes-operator/pull/711
### What changes were proposed in this pull request?
In AppInitStep.reconcile(), when a previous attempt summary exists, the
restart backoff
check now handles the case where
previousAttemptSummary.getStateTransitionHistory() is
null (non-trim mode). Instead of dereferencing it directly (causing an
NPE), the code
falls back to the main status.getStateTransitionHistory() and selects the
state entered
immediately before the current initializing state — the stopping state
that triggered the
restart — using NavigableMap.lowerEntry().
A null guard for getRestartConfig() was also added to the same block.
### Why are the changes needed?
In non-trim mode (TRIM_ATTEMPT_STATE_TRANSITION_HISTORY=false),
ApplicationStatus.terminateOrRestart() sets previousAttemptSummary to the
old
currentAttemptSummary, which always carries stateTransitionHistory = null.
The previous
code called .getStateTransitionHistory().get(...) unconditionally,
throwing a
NullPointerException on every restart attempt in non-trim mode. This
caused the operator
to fail to re-initialize the driver after a restart.
### Does this PR introduce any user-facing change?
No functional behavior change for users running in trim mode (the
default). In non-trim
mode, restart backoff is now correctly enforced instead of crashing with
an NPE.
### How was this patch tested?
Two unit tests were added to AppInitStepTest:
- nonTrimModeRestartBackoffElapsedProceedsToDriverCreation: verifies that
when the backoff has elapsed, the app reaches DriverRequested state without
throwing an NPE (non-trim mode, previousAttemptSummary present with null
stateTransitionHistory).
- nonTrimModeRestartBackoffActiveRequeuesWithDelay: verifies that when the
backoff has not yet elapsed, the reconcile returns a delayed requeue without
throwing an NPE, and the state remains ScheduledToRestart.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Sonnet 4.6
--
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]