Copilot commented on code in PR #722:
URL: https://github.com/apache/solr-operator/pull/722#discussion_r4487967455
##########
controllers/solrcloud_controller.go:
##########
@@ -114,6 +116,27 @@ func (r *SolrCloudReconciler) Reconcile(ctx
context.Context, req ctrl.Request) (
requeueOrNot := reconcile.Result{}
newStatus := solrv1beta1.SolrCloudStatus{}
+ var updateObservedGeneration bool
Review Comment:
`updateObservedGeneration` starts as false and is only ever assigned false,
so the deferred patch is unreachable. For an existing cloud whose new spec
causes an early error (for example, `solrClientTLS` without `solrTLS`), the
generation remains stale despite the operator having processed the change.
Initialize this flag to true so early exits can execute the intended update;
the assignment at the normal status-update path can still disable it.
##########
controllers/solrcloud_controller.go:
##########
@@ -638,8 +661,11 @@ func (r *SolrCloudReconciler) Reconcile(ctx
context.Context, req ctrl.Request) (
}
}
+ updateObservedGeneration = false
+ newStatus.ObservedGeneration = instance.Status.ObservedGeneration
if !reflect.DeepEqual(instance.Status, newStatus) {
logger.Info("Updating SolrCloud Status", "status", newStatus)
+ newStatus.ObservedGeneration = &reconcileGeneration
Review Comment:
Copying the old observed generation before `DeepEqual` prevents a
generation-only change from triggering a status patch. If reconciliation leaves
all other status fields unchanged, `observedGeneration` remains stale or stays
unset on an existing cloud after upgrading the operator. Assign
`reconcileGeneration` before the comparison so the field is persisted even when
the rest of the status is unchanged.
--
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]