Summary
Multiple r.Status().Update() calls at lines 473-484 and 514-526 in axonopsserver_controller.go operate on a potentially stale server object. The CR is not re-fetched before writing status after multiple Create/Update operations. This causes conflict errors and requeue loops.
Detailed Requirements
The Kubernetes API server uses resource versions for optimistic concurrency. When the reconciler performs multiple Create/Update operations on child resources, the server object's resource version becomes stale. Subsequent r.Status().Update() calls fail with 409 Conflict errors, triggering unnecessary requeue cycles.
The fix must add r.Get(ctx, req.NamespacedName, server) before each r.Status().Update() call at the dependency gate points. This follows the controller-runtime best practice documented in AGENTS.md: "Re-fetch before updates."
Location
internal/controller/axonopsserver_controller.go:473-484
internal/controller/axonopsserver_controller.go:514-526
Acceptance Criteria
- CR is re-fetched via
r.Get() before every r.Status().Update() call at dependency gate points
- No conflict errors during normal reconciliation of a complete
AxonOpsServer CR
- Unit test verifies status updates succeed after multiple resource modifications in a single reconcile
- All status update paths in the
Reconcile method follow the re-fetch pattern consistently
Testing Requirements
- Unit test:
TestReconcile_StatusUpdateAfterMultipleResourceCreations — create server with all components, verify no conflict errors
- Unit test: Inject a fake client that returns
Conflict on stale writes, verify the re-fetch resolves it
- Review all other
r.Status().Update() calls in the file for the same pattern
Documentation Requirements
- Add code comment at each re-fetch site explaining why it is necessary
Dependencies
Priority
BLOCKING — causes reconciliation loops and delayed convergence
Summary
Multiple
r.Status().Update()calls at lines 473-484 and 514-526 inaxonopsserver_controller.gooperate on a potentially staleserverobject. The CR is not re-fetched before writing status after multiple Create/Update operations. This causes conflict errors and requeue loops.Detailed Requirements
The Kubernetes API server uses resource versions for optimistic concurrency. When the reconciler performs multiple Create/Update operations on child resources, the
serverobject's resource version becomes stale. Subsequentr.Status().Update()calls fail with409 Conflicterrors, triggering unnecessary requeue cycles.The fix must add
r.Get(ctx, req.NamespacedName, server)before eachr.Status().Update()call at the dependency gate points. This follows the controller-runtime best practice documented in AGENTS.md: "Re-fetch before updates."Location
internal/controller/axonopsserver_controller.go:473-484internal/controller/axonopsserver_controller.go:514-526Acceptance Criteria
r.Get()before everyr.Status().Update()call at dependency gate pointsAxonOpsServerCRReconcilemethod follow the re-fetch pattern consistentlyTesting Requirements
TestReconcile_StatusUpdateAfterMultipleResourceCreations— create server with all components, verify no conflict errorsConflicton stale writes, verify the re-fetch resolves itr.Status().Update()calls in the file for the same patternDocumentation Requirements
Dependencies
Priority
BLOCKING — causes reconciliation loops and delayed convergence