diff --git a/api/v1alpha1/drupalsite_types.go b/api/v1alpha1/drupalsite_types.go index 6a214a7a78bce45f3d202e7e3ca0f6ec35eaf3fc..9eb69e8be9493c432cd1555364a9983ed63058a0 100644 --- a/api/v1alpha1/drupalsite_types.go +++ b/api/v1alpha1/drupalsite_types.go @@ -45,7 +45,7 @@ type DrupalSiteSpec struct { Version `json:"version"` // Configuration of the DrupalSite for specific needs. A typical default value is given for every setting, so usually these won't need to change. - // +kubebuilder:default={"databaseClass":"standard","qosClass":"standard","diskSize":"2000Mi"} + // +kubebuilder:default={"databaseClass":"standard","qosClass":"standard"} // +optional Configuration `json:"configuration,omitempty"` } @@ -92,10 +92,7 @@ type Configuration struct { // +optional CloneFrom `json:"cloneFrom,omitempty"` - // DiskSize is the max size of the site's files directory. The default value is "2000Mi". - // When `cloneFrom` is set, if this value is less than the source's, it will be *overwritten*, - // since the size has to be at least as large as the source. - // +kubebuilder:default="2000Mi" + // DiskSize is the max size of the site's files directory. // +optional // +kubebuilder:validation:Pattern=`^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$` DiskSize string `json:"diskSize,omitempty"` diff --git a/config/crd/bases/drupal.webservices.cern.ch_drupalsites.yaml b/config/crd/bases/drupal.webservices.cern.ch_drupalsites.yaml index b316cb1305c331f9a7bf4070eda2c5b7d8a602d8..3d2aed9bc383bbb7f481e2acb2c7869e302d19fa 100644 --- a/config/crd/bases/drupal.webservices.cern.ch_drupalsites.yaml +++ b/config/crd/bases/drupal.webservices.cern.ch_drupalsites.yaml @@ -39,7 +39,6 @@ spec: configuration: default: databaseClass: standard - diskSize: 2000Mi qosClass: standard description: Configuration of the DrupalSite for specific needs. A typical default value is given for every setting, so usually these @@ -61,11 +60,7 @@ spec: - standard type: string diskSize: - default: 2000Mi description: DiskSize is the max size of the site's files directory. - The default value is "2000Mi". When `cloneFrom` is set, if this - value is less than the source's, it will be *overwritten*, since - the size has to be at least as large as the source. pattern: ^([+-]?[0-9.]+)([eEinumkKMGTP]*[-+]?[0-9]*)$ type: string easystart: diff --git a/controllers/drupalsite_controller.go b/controllers/drupalsite_controller.go index 224d56e94bf995349f320a3a0b7c4f48dfff2d5a..b57432d6dab57a54e4f0b541b46da870b09aee05 100644 --- a/controllers/drupalsite_controller.go +++ b/controllers/drupalsite_controller.go @@ -622,6 +622,10 @@ func (r *DrupalSiteReconciler) ensureSpecFinalizer(ctx context.Context, drp *web drp.Spec.Configuration.WebDAVPassword = generateRandomPassword() update = true } + // Set default value for DiskSize to 2000Mi + if drp.Spec.Configuration.CloneFrom == "" && drp.Spec.Configuration.DiskSize == "" { + drp.Spec.Configuration.DiskSize = "2000Mi" + } // Validate that CloneFrom is an existing DrupalSite if drp.Spec.Configuration.CloneFrom != "" { sourceSite := webservicesv1a1.DrupalSite{} @@ -636,6 +640,10 @@ func (r *DrupalSiteReconciler) ensureSpecFinalizer(ctx context.Context, drp *web if drp.Spec.Configuration.DiskSize < sourceSite.Spec.Configuration.DiskSize { drp.Spec.Configuration.DiskSize = sourceSite.Spec.Configuration.DiskSize } + // The extraConfigurationRepo should be set in the clone site if defined in the source + if sourceSite.Spec.Configuration.ExtraConfigurationRepo != "" && drp.Spec.Configuration.ExtraConfigurationRepo == "" { + drp.Spec.Configuration.ExtraConfigurationRepo = sourceSite.Spec.Configuration.ExtraConfigurationRepo + } } // Initialize 'spec.version.releaseSpec' if empty if len(drp.Spec.Version.ReleaseSpec) == 0 { diff --git a/controllers/drupalsite_controller_test.go b/controllers/drupalsite_controller_test.go index ee5038fd1e78961b90915f617a20e86a85b1efbc..25db9b8012e5b123326bf90275930ed693dc4971 100644 --- a/controllers/drupalsite_controller_test.go +++ b/controllers/drupalsite_controller_test.go @@ -1188,6 +1188,7 @@ var _ = Describe("DrupalSite controller", func() { return string(cr.Spec.Configuration.DatabaseClass) == string(drupalwebservicesv1alpha1.DBODStandard) }, timeout, interval).Should(BeTrue()) Eventually(func() bool { + k8sClient.Get(ctx, key, &cr) return string(cr.Spec.Configuration.DiskSize) == "2000Mi" }, timeout, interval).Should(BeTrue()) @@ -1374,6 +1375,7 @@ var _ = Describe("DrupalSite controller", func() { return string(cr.Spec.Configuration.DatabaseClass) == string(drupalwebservicesv1alpha1.DBODStandard) }, timeout, interval).Should(BeTrue()) Eventually(func() bool { + k8sClient.Get(ctx, key, &cr) return string(cr.Spec.Configuration.DiskSize) == "2000Mi" }, timeout, interval).Should(BeTrue())