Skip to content

Commit

Permalink
Update ClusterLogForwarder status when ClusterLogging becomes valid
Browse files Browse the repository at this point in the history
After a valid ClusterLogForwarder and an invalid ClusterLogging resource
are created, the ClusterLogForwarder's status will show that the CLF is
not available. When the ClusterLogging CR is then changes to a valid
configuration, the CLF's status should reflect that everything is o.k.
now.

Signed-off-by: Andreas Karis <ak.karis@gmail.com>
  • Loading branch information
andreaskaris committed Jan 18, 2024
1 parent a51953a commit 894ba99
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion controllers/clusterlogging/clusterlogging_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,18 @@ func (r *ReconcileClusterLogging) Reconcile(ctx context.Context, request ctrl.Re
telemetry.Data.CLInfo.Set("managedStatus", constants.UnManagedStatus)
return ctrl.Result{}, nil
}
clf, err, _ := loader.FetchClusterLogForwarder(r.Client, request.NamespacedName.Namespace, request.NamespacedName.Name, false, func() loggingv1.ClusterLogging { return instance })
clf, err, cls := loader.FetchClusterLogForwarder(r.Client, request.NamespacedName.Namespace, request.NamespacedName.Name, false, func() loggingv1.ClusterLogging { return instance })
if err != nil && !errors.IsNotFound(err) {
return ctrl.Result{}, err
}
// Make sure that the ClusterForwarder status is updated as well, as we might migrate from an invalid to a valid
// configuration or vice versa.
clf.Status.Synchronize(cls)
defer func() {
if err := r.Client.Status().Update(ctx, &clf); err != nil {
log.Error(err, "Error while updating status for ClusterLoggingForwarder %s/%s", clf.Namespace, clf.Name)
}
}()

clusterVersion, clusterID := r.GetClusterVersionID(ctx, request.Namespace)
resourceNames := factory.GenerateResourceNames(clf)
Expand Down

0 comments on commit 894ba99

Please sign in to comment.