Skip to content

Commit

Permalink
controller: Introduce updateClusterInfo function
Browse files Browse the repository at this point in the history
This commit moves code that runs inline on the reconcile loop and
updates clusterInfo.IsSingleReplica.
This code will now run on a new function, that in future commits will
update other clusterInfo params.

Signed-off-by: Ram Lavi <[email protected]>
  • Loading branch information
RamLavi committed Aug 5, 2024
1 parent 15f674f commit 3613643
Showing 1 changed file with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,15 @@ func (r *ReconcileNetworkAddonsConfig) Reconcile(ctx context.Context, request re
return reconcile.Result{}, nil
}

if r.clusterInfo.OpenShift4 {
isSingleReplica, err := isOpenshiftSingleReplica(r.client)
if err != nil {
log.Printf("failed to check if running on a singleReplica infrastrcuture: %v", err)
}
r.clusterInfo.IsSingleReplica = isSingleReplica
err := r.updateClusterInfo()
if err != nil {
r.statusManager.SetFailing(statusmanager.OperatorConfig, "updateClusterInfo", err.Error())
return reconcile.Result{}, err
}

// Fetch the NetworkAddonsConfig instance
networkAddonsConfigStorageVersion := &cnaov1.NetworkAddonsConfig{}
err := r.client.Get(context.TODO(), request.NamespacedName, networkAddonsConfigStorageVersion)
err = r.client.Get(context.TODO(), request.NamespacedName, networkAddonsConfigStorageVersion)
if err != nil {
if apierrors.IsNotFound(err) {
// Request object not found, could have been deleted after reconcile request.
Expand Down Expand Up @@ -509,6 +507,19 @@ func (r *ReconcileNetworkAddonsConfig) stopTrackingObjects() {
r.statusManager.SetFromPods()
}

// updateClusterInfo checks specific params in cluster-info struct and updates them.
func (r *ReconcileNetworkAddonsConfig) updateClusterInfo() error {
if r.clusterInfo.OpenShift4 {
isSingleReplica, err := isOpenshiftSingleReplica(r.client)
if err != nil {
log.Printf("failed to check if running on a singleReplica infrastrcuture: %v", err)
}
r.clusterInfo.IsSingleReplica = isSingleReplica
}

return nil
}

func updateObjectsLabels(crLabels map[string]string, objs []*unstructured.Unstructured) error {
var err error
for _, obj := range objs {
Expand Down

0 comments on commit 3613643

Please sign in to comment.