You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by ho...@apache.org on 2022/11/01 14:27:14 UTC

[solr-operator] branch main updated: Fix bug with named PVCs (#481)

This is an automated email from the ASF dual-hosted git repository.

houston pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr-operator.git


The following commit(s) were added to refs/heads/main by this push:
     new 0539494  Fix bug with named PVCs (#481)
0539494 is described below

commit 0539494189c6634b6ecb91ac5e09809df4c5b630
Author: Houston Putman <ho...@apache.org>
AuthorDate: Tue Nov 1 10:27:09 2022 -0400

    Fix bug with named PVCs (#481)
---
 api/v1beta1/solrbackup_types.go                   |  2 +-
 api/v1beta1/solrcloud_types.go                    | 13 +++++++++++--
 config/crd/bases/solr.apache.org_solrbackups.yaml |  4 ++--
 config/crd/bases/solr.apache.org_solrclouds.yaml  |  2 +-
 controllers/util/solr_update_util.go              |  5 +++--
 controllers/util/solr_util.go                     |  9 ++-------
 helm/solr-operator/Chart.yaml                     | 11 ++++-------
 helm/solr-operator/crds/crds.yaml                 |  6 +++---
 8 files changed, 27 insertions(+), 25 deletions(-)

diff --git a/api/v1beta1/solrbackup_types.go b/api/v1beta1/solrbackup_types.go
index 3233f0e..d0cf6a2 100644
--- a/api/v1beta1/solrbackup_types.go
+++ b/api/v1beta1/solrbackup_types.go
@@ -121,7 +121,7 @@ type IndividualSolrBackupStatus struct {
 	// +optional
 	CollectionBackupStatuses []CollectionBackupStatus `json:"collectionBackupStatuses,omitempty"`
 
-	// Version of the Solr being backed up
+	// The time that this backup was finished
 	// +optional
 	FinishTime *metav1.Time `json:"finishTimestamp,omitempty"`
 
diff --git a/api/v1beta1/solrcloud_types.go b/api/v1beta1/solrcloud_types.go
index 29933f5..1d2f6f8 100644
--- a/api/v1beta1/solrcloud_types.go
+++ b/api/v1beta1/solrcloud_types.go
@@ -844,8 +844,7 @@ type ZookeeperSpec struct {
 	// +optional
 	ReadOnlyACL *ZookeeperACL `json:"readOnlyAcl,omitempty"`
 
-	// ZooKeeper ACL to use when connecting with ZK for reading operations.
-	// This ACL should have READ permission in the given chRoot.
+	// Additional Zookeeper Configuration settings
 	// +optional
 	Config ZookeeperConfig `json:"config,omitempty"`
 }
@@ -1418,6 +1417,16 @@ func (sc *SolrCloud) UsesPersistentStorage() bool {
 	return sc.Spec.StorageOptions.PersistentStorage != nil
 }
 
+func (sc *SolrCloud) DataVolumeName() string {
+	// Set the default name of the pvc
+	if sc.Spec.StorageOptions.PersistentStorage != nil &&
+		sc.Spec.StorageOptions.PersistentStorage.PersistentVolumeClaimTemplate.ObjectMeta.Name != "" {
+		return sc.Spec.StorageOptions.PersistentStorage.PersistentVolumeClaimTemplate.ObjectMeta.Name
+	} else {
+		return "data"
+	}
+}
+
 func (sc *SolrCloud) SharedLabels() map[string]string {
 	return sc.SharedLabelsWith(map[string]string{})
 }
diff --git a/config/crd/bases/solr.apache.org_solrbackups.yaml b/config/crd/bases/solr.apache.org_solrbackups.yaml
index 9a59c1a..f0d10e0 100644
--- a/config/crd/bases/solr.apache.org_solrbackups.yaml
+++ b/config/crd/bases/solr.apache.org_solrbackups.yaml
@@ -153,7 +153,7 @@ spec:
                   type: object
                 type: array
               finishTimestamp:
-                description: Version of the Solr being backed up
+                description: The time that this backup was finished
                 format: date-time
                 type: string
               finished:
@@ -200,7 +200,7 @@ spec:
                         type: object
                       type: array
                     finishTimestamp:
-                      description: Version of the Solr being backed up
+                      description: The time that this backup was finished
                       format: date-time
                       type: string
                     finished:
diff --git a/config/crd/bases/solr.apache.org_solrclouds.yaml b/config/crd/bases/solr.apache.org_solrclouds.yaml
index fa7c065..b18aa49 100644
--- a/config/crd/bases/solr.apache.org_solrclouds.yaml
+++ b/config/crd/bases/solr.apache.org_solrclouds.yaml
@@ -5267,7 +5267,7 @@ spec:
                         description: The ChRoot to connect solr at
                         type: string
                       config:
-                        description: ZooKeeper ACL to use when connecting with ZK for reading operations. This ACL should have READ permission in the given chRoot.
+                        description: Additional Zookeeper Configuration settings
                         properties:
                           additionalConfig:
                             additionalProperties:
diff --git a/controllers/util/solr_update_util.go b/controllers/util/solr_update_util.go
index 7bf5690..ab91dba 100644
--- a/controllers/util/solr_update_util.go
+++ b/controllers/util/solr_update_util.go
@@ -482,15 +482,16 @@ func GetAllManagedSolrNodeNames(solrCloud *solr.SolrCloud) map[string]bool {
 // This function MUST be idempotent and return the same list of pods given the same kubernetes/solr state.
 func EvictReplicasForPodIfNecessary(ctx context.Context, solrCloud *solr.SolrCloud, pod *corev1.Pod, logger logr.Logger) (err error, canDeletePod bool) {
 	var solrDataVolume *corev1.Volume
+	dataVolumeName := solrCloud.DataVolumeName()
 	for _, volume := range pod.Spec.Volumes {
-		if volume.Name == SolrDataVolumeName {
+		if volume.Name == dataVolumeName {
 			solrDataVolume = &volume
 			break
 		}
 	}
 
 	// Only evict if the Data volume is not persistent
-	if solrDataVolume.VolumeSource.PersistentVolumeClaim == nil {
+	if solrDataVolume != nil && solrDataVolume.VolumeSource.PersistentVolumeClaim == nil {
 		// If the Cloud has 1 or zero pods, and this is the "-0" pod, then delete the data since we can't move it anywhere else
 		// Otherwise, move the replicas to other pods
 		if (solrCloud.Spec.Replicas == nil || *solrCloud.Spec.Replicas < 2) && strings.HasSuffix(pod.Name, "-0") {
diff --git a/controllers/util/solr_util.go b/controllers/util/solr_util.go
index 0223bb0..5bc95c0 100644
--- a/controllers/util/solr_util.go
+++ b/controllers/util/solr_util.go
@@ -45,7 +45,6 @@ const (
 	SolrCloudPVCTechnology           = "solr-cloud"
 	SolrPVCStorageLabel              = "solr.apache.org/storage"
 	SolrCloudPVCDataStorage          = "data"
-	SolrDataVolumeName               = "data"
 	SolrPVCInstanceLabel             = "solr.apache.org/instance"
 	SolrXmlMd5Annotation             = "solr.apache.org/solrXmlMd5"
 	SolrXmlFile                      = "solr.xml"
@@ -143,18 +142,14 @@ func GenerateStatefulSet(solrCloud *solr.SolrCloud, solrCloudStatus *solr.SolrCl
 		},
 	}
 
-	solrDataVolumeName := SolrDataVolumeName
+	solrDataVolumeName := solrCloud.DataVolumeName()
 
 	var pvcs []corev1.PersistentVolumeClaim
 	if solrCloud.UsesPersistentStorage() {
 		pvc := solrCloud.Spec.StorageOptions.PersistentStorage.PersistentVolumeClaimTemplate.DeepCopy()
 
 		// Set the default name of the pvc
-		if pvc.ObjectMeta.Name == "" {
-			pvc.ObjectMeta.Name = solrDataVolumeName
-		} else {
-			solrDataVolumeName = pvc.ObjectMeta.Name
-		}
+		pvc.ObjectMeta.Name = solrDataVolumeName
 
 		// Set some defaults in the PVC Spec
 		if len(pvc.Spec.AccessModes) == 0 {
diff --git a/helm/solr-operator/Chart.yaml b/helm/solr-operator/Chart.yaml
index d5c7da0..8446dc9 100644
--- a/helm/solr-operator/Chart.yaml
+++ b/helm/solr-operator/Chart.yaml
@@ -53,16 +53,13 @@ annotations:
   # Add change log for a single release here.
   # Allowed syntax is described at: https://artifacthub.io/docs/topics/annotations/helm/#example
   artifacthub.io/changes: |
-    - kind: added
-      description: Addition 1
+    - kind: fixed
+      description: Fix bug with named PVCs
       links:
         - name: Github Issue
-          url: https://github.com/issue-url
-    - kind: changed
-      description: Change 2
-      links:
+          url: https://github.com/apache/solr-operator/issues/479
         - name: Github PR
-          url: https://github.com/pr-url
+          url: https://github.com/apache/solr-operator/pull/481
   artifacthub.io/images: |
     - name: solr-operator
       image: apache/solr-operator:v0.7.0-prerelease
diff --git a/helm/solr-operator/crds/crds.yaml b/helm/solr-operator/crds/crds.yaml
index a3c4bbc..2338291 100644
--- a/helm/solr-operator/crds/crds.yaml
+++ b/helm/solr-operator/crds/crds.yaml
@@ -153,7 +153,7 @@ spec:
                   type: object
                 type: array
               finishTimestamp:
-                description: Version of the Solr being backed up
+                description: The time that this backup was finished
                 format: date-time
                 type: string
               finished:
@@ -200,7 +200,7 @@ spec:
                         type: object
                       type: array
                     finishTimestamp:
-                      description: Version of the Solr being backed up
+                      description: The time that this backup was finished
                       format: date-time
                       type: string
                     finished:
@@ -5499,7 +5499,7 @@ spec:
                         description: The ChRoot to connect solr at
                         type: string
                       config:
-                        description: ZooKeeper ACL to use when connecting with ZK for reading operations. This ACL should have READ permission in the given chRoot.
+                        description: Additional Zookeeper Configuration settings
                         properties:
                           additionalConfig:
                             additionalProperties: