From dced581da30d4b5b052801035543530fd39e51af Mon Sep 17 00:00:00 2001 From: Rajula Vineet Reddy <rajula.vineet.reddy@cern.ch> Date: Fri, 21 Oct 2022 11:50:39 +0200 Subject: [PATCH] Ensure update is true when modiyfing CR in ensureSpecFinalizer --- controllers/drupalsite_controller_utils.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/controllers/drupalsite_controller_utils.go b/controllers/drupalsite_controller_utils.go index 9482d552..bcd107b4 100644 --- a/controllers/drupalsite_controller_utils.go +++ b/controllers/drupalsite_controller_utils.go @@ -175,6 +175,7 @@ func (r *DrupalSiteReconciler) cleanupDrupalSite(ctx context.Context, log logr.L // ensureSpecFinalizer ensures that the spec is valid, adding extra info if necessary, and that the finalizer is there, // then returns if it needs to be updated. func (r *DrupalSiteReconciler) ensureSpecFinalizer(ctx context.Context, drp *webservicesv1a1.DrupalSite, log logr.Logger) (update bool, err reconcileError) { + // We want the update variable to be true, only when we make changes to the CR & want it to be updated if !controllerutil.ContainsFinalizer(drp, finalizerStr) { log.V(3).Info("Adding finalizer") controllerutil.AddFinalizer(drp, finalizerStr) @@ -203,18 +204,20 @@ func (r *DrupalSiteReconciler) ensureSpecFinalizer(ctx context.Context, drp *web // The destination disk size must be at least as large as the source if drp.Spec.Configuration.DiskSize < sourceSite.Spec.Configuration.DiskSize { drp.Spec.Configuration.DiskSize = sourceSite.Spec.Configuration.DiskSize + update = true } // The extraConfigurationRepo should be set in the clone site if defined in the source // TODO: Remove logic for ExtraConfigurationRepo once we deprecate the field if sourceSite.Spec.Configuration.ExtraConfigurationRepo != "" && drp.Spec.Configuration.ExtraConfigurationRepo == "" { drp.Spec.Configuration.ExtraConfigurationRepo = sourceSite.Spec.Configuration.ExtraConfigurationRepo + update = true } // The extraConfigurationRepository should be set in the clone site if defined in the source if sourceSite.Spec.Configuration.ExtraConfigurationRepository.Branch != "" && sourceSite.Spec.Configuration.ExtraConfigurationRepository.RepositoryUrl != "" && drp.Spec.Configuration.ExtraConfigurationRepository.Branch == "" && drp.Spec.Configuration.ExtraConfigurationRepository.RepositoryUrl != "" { drp.Spec.Configuration.ExtraConfigurationRepository.Branch = sourceSite.Spec.Configuration.ExtraConfigurationRepository.Branch drp.Spec.Configuration.ExtraConfigurationRepository.RepositoryUrl = sourceSite.Spec.Configuration.ExtraConfigurationRepository.RepositoryUrl + update = true } - // if it's a clone it should not change update, to allow continuing with the deployment } // Initialize 'spec.version.releaseSpec' if empty @@ -233,7 +236,7 @@ func (r *DrupalSiteReconciler) ensureSpecFinalizer(ctx context.Context, drp *web } // Error reading the object - fail the request. log.Error(err, fmt.Sprintf("Failed to get SupportedDrupalVersions '%s'", SupportedDrupalVersionName)) - return update, newApplicationError(err, ErrClientK8s) + return false, newApplicationError(err, ErrClientK8s) } // Iterate over available versions to find if the one requested has a ReleaseSpec for _, v := range supportedDrupalVersions.Status.AvailableVersions { -- GitLab