diff --git a/controllers/drupalsite_controller_utils.go b/controllers/drupalsite_controller_utils.go index 9482d552fda954d56e1bce4451250bab818d3fd2..bcd107b4ca198c882622619779fbf5c94ad7d59d 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 {