Commit 933605a
committed
### What changes were proposed in this pull request?
This PR fixes the `StatusRecorder.patchAndStatusWithVersionLocked()` retry loop to refresh the `resourceVersion` from the API server when a 409 Conflict occurs, before retrying the status update.
### Why are the changes needed?
When a 409 Conflict (`"the object has been modified; please apply your changes to the latest version"`) occurs during a status update, the retry loop retries with the same stale `resourceVersion`, causing all subsequent retries to fail with the same conflict error. The fix fetches the latest resource from the API server on 409 to obtain the current `resourceVersion`, following the existing pattern used in `ReconcilerUtils`.
```
26/03/26 02:10:34 ERROR pi default o.a.s.k.o.u.StatusRecorder
Error while persisting status to
ApplicationStatus(super=BaseStatus(currentState=ApplicationState(super=BaseState(currentStateSummary=ResourceReleased, lastTransitionTime=2026-03-26T02:10:31.642213107Z, message=null), lastObservedDriverStatus=null), stateTransitionHistory={0=ApplicationState(super=BaseState(currentStatio.fabric8.kubernetes.client.KubernetesClientException:
Failure executing: PUT at: https://10.43.0.1:443/apis/spark.apache.org/v1/namespaces/default/sparkapplications/pi/status.
Message: Operation cannot be fulfilled on sparkapplications.spark.apache.org "pi":
the object has been modified; please apply your changes to the latest version and try again. Received status: Status(apiV
at io.fabric8.kubernetes.client.KubernetesClientException.copyAsCause(KubernetesClientException.java:205)
at io.fabric8.kubernetes.client.dsl.internal.OperationSupport.waitForResult(OperationSupport.java:507)
at io.fabric8.kubernetes.client.dsl.internal.OperationSupport.handleResponse(OperationSupport.java:524)
at io.fabric8.kubernetes.client.dsl.internal.OperationSupport.handleUpdate(OperationSupport.java:358)
at io.fabric8.kubernetes.client.dsl.internal.BaseOperation.handleUpdate(BaseOperation.java:771)
at io.fabric8.kubernetes.client.dsl.internal.HasMetadataOperation.update(HasMetadataOperation.java:138)
at io.fabric8.kubernetes.client.dsl.internal.HasMetadataOperation.update(HasMetadataOperation.java:121)
at io.fabric8.kubernetes.client.dsl.internal.HasMetadataOperation.updateStatus(HasMetadataOperation.java:126)
at io.fabric8.kubernetes.client.dsl.internal.HasMetadataOperation.updateStatus(HasMetadataOperation.java:44)
at org.apache.spark.k8s.operator.utils.StatusRecorder.patchAndStatusWithVersionLocked(StatusRecorder.java:99)
```
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
A new unit test `refreshesResourceVersionOn409Conflict` was added to `StatusRecorderTest` to verify that the `resourceVersion` is refreshed after a 409 Conflict and the retry succeeds.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Claude Code (claude-opus-4-6)
Closes #592 from dongjoon-hyun/SPARK-56228.
Authored-by: Dongjoon Hyun <dongjoon@apache.org>
Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
1 parent a2d216e commit 933605a
2 files changed
Lines changed: 44 additions & 0 deletions
File tree
- spark-operator/src
- main/java/org/apache/spark/k8s/operator/utils
- test/java/org/apache/spark/k8s/operator/utils
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
102 | 103 | | |
103 | 104 | | |
104 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
105 | 118 | | |
106 | 119 | | |
107 | 120 | | |
| |||
Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
59 | 90 | | |
60 | 91 | | |
61 | 92 | | |
| |||
0 commit comments