From 8ddf580c6b183508fbd0d5347b14b840c0f62db0 Mon Sep 17 00:00:00 2001
From: Dimitra Chatzichrysou <dimitra.chatzichrysou@cern.ch>
Date: Mon, 14 Feb 2022 12:28:47 +0100
Subject: [PATCH 1/4] Copy config on clone by default

---
 controllers/drupalsite_controller.go | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/controllers/drupalsite_controller.go b/controllers/drupalsite_controller.go
index 224d56e9..87eddbea 100644
--- a/controllers/drupalsite_controller.go
+++ b/controllers/drupalsite_controller.go
@@ -636,6 +636,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 {
-- 
GitLab


From 7b1659715140af590f174090a85373dc1c58a0a9 Mon Sep 17 00:00:00 2001
From: Dimitra Chatzichrysou <dimitra.chatzichrysou@cern.ch>
Date: Tue, 15 Feb 2022 12:32:55 +0100
Subject: [PATCH 2/4] Remove diskSize default value from CRD

---
 api/v1alpha1/drupalsite_types.go                           | 7 ++-----
 .../crd/bases/drupal.webservices.cern.ch_drupalsites.yaml  | 5 -----
 2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/api/v1alpha1/drupalsite_types.go b/api/v1alpha1/drupalsite_types.go
index 6a214a7a..9eb69e8b 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 b316cb13..3d2aed9b 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:
-- 
GitLab


From 92722ae4178f11934d9fbc7bdf330d75d1d914a5 Mon Sep 17 00:00:00 2001
From: Dimitra Chatzichrysou <dimitra.chatzichrysou@cern.ch>
Date: Tue, 15 Feb 2022 13:01:43 +0100
Subject: [PATCH 3/4] Set default value for diskSize

---
 controllers/drupalsite_controller.go | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/controllers/drupalsite_controller.go b/controllers/drupalsite_controller.go
index 87eddbea..b57432d6 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{}
-- 
GitLab


From fb8bbd715ac237e0a20bc882a3e31ed1e33e7bb5 Mon Sep 17 00:00:00 2001
From: Dimitra Chatzichrysou <dimitra.chatzichrysou@cern.ch>
Date: Wed, 16 Feb 2022 11:46:56 +0100
Subject: [PATCH 4/4] Update tests

---
 controllers/drupalsite_controller_test.go | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/controllers/drupalsite_controller_test.go b/controllers/drupalsite_controller_test.go
index ee5038fd..25db9b80 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())
 
-- 
GitLab