Skip to content

Commit ab6be13

Browse files
author
Francisco Barros
committed
Cosmetic changes
1 parent dd7656e commit ab6be13

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

controllers/drupalsite_controller.go

+13-11
Original file line numberDiff line numberDiff line change
@@ -326,13 +326,13 @@ func (r *DrupalSiteReconciler) Reconcile(ctx context.Context, req ctrl.Request)
326326
}
327327
}
328328
}
329-
// TODO: Check if Primary DrupalSite HAS a website, and if it does NOT + This DrupalSIte instance is unique -> Become Primary Website
329+
// Check if Primary DrupalSite HAS a website, and if it does NOT + This DrupalSIte instance is unique -> Become Primary Website
330330
if needsUpdate, err, dpc := r.checkIfPrimaryDrupalsiteExists(ctx, drupalSite); err != nil {
331331
log.Error(err, fmt.Sprintf("%v failed to validate if DrupalSite is Primary", err.Unwrap()))
332332
setErrorCondition(drupalSite, err)
333333
return r.updateCRStatusOrFailReconcile(ctx, log, drupalSite)
334334
} else if needsUpdate {
335-
log.Info("Updating DrupalProjectConfig of project %s", drupalSite.Namespace, "")
335+
log.Info("Updating DrupalProjectConfig", "")
336336
return r.updateDrupalProjectConfigCRorFailReconcile(ctx, log, dpc)
337337
}
338338

@@ -342,7 +342,6 @@ func (r *DrupalSiteReconciler) Reconcile(ctx context.Context, req ctrl.Request)
342342
setErrorCondition(drupalSite, err)
343343
return r.updateCRStatusOrFailReconcile(ctx, log, drupalSite)
344344
} else if needsUpdate {
345-
log.Info("Updating IsPrimary Site Status of %s", drupalSite.Name, "")
346345
return r.updateCRStatusOrFailReconcile(ctx, log, drupalSite)
347346
}
348347

@@ -859,25 +858,28 @@ func (r *DrupalSiteReconciler) checkIfPrimaryDrupalsiteExists(ctx context.Contex
859858
}
860859

861860
//checkIfPrimaryDrupalSite checks if current DrupalSite is primary or not in the project
862-
func (r *DrupalSiteReconciler) checkIfPrimaryDrupalsite(ctx context.Context, drp *webservicesv1a1.DrupalSite) (bool, reconcileError) {
861+
func (r *DrupalSiteReconciler) checkIfPrimaryDrupalsite(ctx context.Context, drp *webservicesv1a1.DrupalSite) (update bool, reconcileErr reconcileError) {
862+
update = false
863863
// Fetch the DrupalProjectConfigList on the Namespace
864864
drupalProjectConfigList := &webservicesv1a1.DrupalProjectConfigList{}
865865
if err := r.List(ctx, drupalProjectConfigList, &client.ListOptions{Namespace: drp.Namespace}); err != nil {
866-
return false, newApplicationError(errors.New("fetching drupalProjectConfigList failed"), ErrClientK8s)
866+
reconcileErr = newApplicationError(errors.New("fetching drupalProjectConfigList failed"), ErrClientK8s)
867+
return
867868
}
868869
if len(drupalProjectConfigList.Items) == 0 {
869870
r.Log.Info("Warning: Project %s does not contain any DrupalProjectConfig!", drp.Namespace)
870-
return false, nil
871+
return
871872
}
872873
// We get the first DrupalProjectConfig in the Namespace, only one is expected per cluster!
873874
drupalProjectConfig := drupalProjectConfigList.Items[0]
874875
if drp.Name == drupalProjectConfig.Spec.PrimarySiteName && !drp.Status.IsPrimary {
876+
update = true
875877
drp.Status.IsPrimary = true
876-
return true, nil
877-
}
878-
if drp.Name != drupalProjectConfig.Spec.PrimarySiteName && drp.Status.IsPrimary {
878+
return
879+
} else if drp.Name != drupalProjectConfig.Spec.PrimarySiteName && drp.Status.IsPrimary {
880+
update = true
879881
drp.Status.IsPrimary = false
880-
return true, nil
882+
return
881883
}
882-
return false, nil
884+
return
883885
}

controllers/reconciler_utils.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (r *DrupalSiteReconciler) updateDrupalProjectConfigCRorFailReconcile(ctx co
131131
log.Error(err, fmt.Sprintf("%v failed to update the application", ErrClientK8s))
132132
return reconcile.Result{}, err
133133
}
134-
return reconcile.Result{}, nil
134+
return reconcile.Result{Requeue: true}, nil
135135
}
136136

137137
// updateCRorFailReconcile tries to update the Custom Resource and logs any error

0 commit comments

Comments
 (0)