Skip to content

Commit

Permalink
controller: update operator status on successful reconciliation
Browse files Browse the repository at this point in the history
We have been seeing several cases where the operator status doesn't get
updated correctly yet it's been hard to reproduce and track down the
reason (see https://issues.redhat.com/browse/OCPBUGS-16058 &
https://issues.redhat.com/browse/CNF-9080).

During the updates of the controller tests to extend the coverage of
reflecting the node group config under the status, with further
debugging it turned out that updating the operator status was skipped
in case of 2 similar successive conditions. This is wrong because each
condition status can vary with the reasons, for example, the operator is
successful with one set of NodeGroupConfig and later is configured with
another successful set of settings, which we still want to reflect.
Fortunately this is just a status reflection that explains why the RTE
daemonset for example gets updated even if the status on the NROP CR is
not up-to-date.

Fix this by relaxing the updateStatus() function not to make it a hard
requirement on the successive conditions to unmatch, and thus allowing
always update the status after the end of each reconciliation loop.

candidate fix for openshift-kni#920

Signed-off-by: Shereen Haj <[email protected]>
  • Loading branch information
shajmakh committed Oct 17, 2024
1 parent 35d30b6 commit bb5490f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions controllers/numaresourcesoperator_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,11 @@ func (r *NUMAResourcesOperatorReconciler) updateStatus(ctx context.Context, inst

func updateStatus(ctx context.Context, cli client.Client, instance *nropv1.NUMAResourcesOperator, condition string, reason string, message string) (bool, error) {
conditions, ok := status.GetUpdatedConditions(instance.Status.Conditions, condition, reason, message)
if !ok {
return false, nil
if ok {
instance.Status.Conditions = conditions
}
instance.Status.Conditions = conditions

// in case of a 2 similar successive conditions happen we still want to update the status to get latest status updates
if err := cli.Status().Update(ctx, instance); err != nil {
return false, fmt.Errorf("could not update status for object %s: %w", client.ObjectKeyFromObject(instance), err)
}
Expand Down

0 comments on commit bb5490f

Please sign in to comment.