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/03/11 16:44:44 UTC

[solr-operator] branch main updated: Rename additionalDomains to additionalDomainNames (#416)

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 b7747cf  Rename additionalDomains to additionalDomainNames (#416)
b7747cf is described below

commit b7747cfdb5e003e4fd792966042980a2c557b449
Author: Houston Putman <ho...@apache.org>
AuthorDate: Fri Mar 11 11:44:38 2022 -0500

    Rename additionalDomains to additionalDomainNames (#416)
    
    Co-authored-by: Marco Moscher <mo...@modell-aachen.de>
---
 api/v1beta1/solrcloud_types.go                   | 39 ++++++++++++++-
 api/v1beta1/solrcloud_with_defaults_test.go      | 64 ++++++++++++++++++++++++
 api/v1beta1/zz_generated.deepcopy.go             |  5 ++
 config/crd/bases/solr.apache.org_solrclouds.yaml |  7 ++-
 docs/upgrade-notes.md                            |  4 ++
 helm/solr-operator/Chart.yaml                    |  7 +++
 helm/solr-operator/crds/crds.yaml                |  7 ++-
 helm/solr/Chart.yaml                             |  7 +++
 8 files changed, 137 insertions(+), 3 deletions(-)

diff --git a/api/v1beta1/solrcloud_types.go b/api/v1beta1/solrcloud_types.go
index 554d7df..cd77a07 100644
--- a/api/v1beta1/solrcloud_types.go
+++ b/api/v1beta1/solrcloud_types.go
@@ -560,7 +560,15 @@ type ExternalAddressability struct {
 	// Provide additional domainNames that the Ingress or ExternalDNS should listen on.
 	// This option is ignored with the LoadBalancer method.
 	// +optional
-	AdditionalDomainNames []string `json:"additionalDomains,omitempty"`
+	AdditionalDomainNames []string `json:"additionalDomainNames,omitempty"`
+
+	// Provide additional domainNames that the Ingress or ExternalDNS should listen on.
+	// This option is ignored with the LoadBalancer method.
+	//
+	// DEPRECATED: Please use additionalDomainNames instead. This will be removed in a future version.
+	//
+	// +optional
+	AdditionalDomains []string `json:"additionalDomains,omitempty"`
 
 	// NodePortOverride defines the port to have all Solr node service(s) listen on and advertise itself as if advertising through an Ingress or LoadBalancer.
 	// This overrides the default usage of the podPort.
@@ -609,6 +617,35 @@ func (opts *ExternalAddressability) withDefaults(usesTLS bool) (changed bool) {
 		changed = true
 		opts.UseExternalAddress = false
 	}
+
+	// Add the values from the deprecated "additionalDomains" to the new "additionalDomainNames" field
+	// But make sure you aren't creating duplicates
+	// TODO: Remove in v0.7.0
+	if opts.AdditionalDomains != nil {
+		// Only modify AdditionalDomainNames if AdditionalDomains is empty
+		// But if it is non-nil and empty, still set AdditionalDomains to nil
+		if len(opts.AdditionalDomains) > 0 {
+			if len(opts.AdditionalDomainNames) == 0 {
+				opts.AdditionalDomainNames = opts.AdditionalDomains
+			} else {
+				for _, domain := range opts.AdditionalDomains {
+					hasDomain := false
+					for _, containsDomain := range opts.AdditionalDomainNames {
+						if domain == containsDomain {
+							hasDomain = true
+							break
+						}
+					}
+					if !hasDomain {
+						opts.AdditionalDomainNames = append(opts.AdditionalDomainNames, domain)
+					}
+				}
+			}
+		}
+		changed = true
+		opts.AdditionalDomains = nil
+	}
+
 	// If the Ingress method is used, default the nodePortOverride to 80 or 443, since that is the port that most ingress controllers listen on.
 	if !opts.HideNodes && opts.Method == Ingress && opts.NodePortOverride == 0 {
 		changed = true
diff --git a/api/v1beta1/solrcloud_with_defaults_test.go b/api/v1beta1/solrcloud_with_defaults_test.go
index 474be2e..d187b4c 100644
--- a/api/v1beta1/solrcloud_with_defaults_test.go
+++ b/api/v1beta1/solrcloud_with_defaults_test.go
@@ -103,3 +103,67 @@ func assertLegacyBackupRepo(t *testing.T, repository SolrBackupRepository, volum
 	assert.EqualValuesf(t, volume, repository.Volume.Source, "Volume Source incorrectly copied over for legacy backup repo")
 	assert.Equal(t, dir, repository.Volume.Directory, "Directory incorrectly copied over for legacy backup repo")
 }
+
+func TestDeprecatedAdditionalDomains(t *testing.T) {
+	ext := &ExternalAddressability{}
+
+	assert.False(t, ext.withDefaults(false), "withDefaults() returned true when nothing should have been changed (no additional domains in either field)")
+
+	ext.AdditionalDomainNames = []string{"t1", "t2"}
+
+	assert.False(t, ext.withDefaults(false), "withDefaults() returned true when nothing should have been changed (no additional domains in the deprecated field)")
+
+	ext.AdditionalDomains = nil
+
+	assert.False(t, ext.withDefaults(false), "withDefaults() returned true when nothing should have been changed (no additional domains in the deprecated field)")
+
+	ext.AdditionalDomains = []string{}
+
+	assert.True(t, ext.withDefaults(false), "withDefaults() returned false when the additionalDomains field needs to be removed")
+	assert.ElementsMatch(t, []string{"t1", "t2"}, ext.AdditionalDomainNames, "There are no values from additionalDomains to append to additionalDomainNames")
+	assert.Nil(t, ext.AdditionalDomains, "The additionalDomains field was not set to nil")
+
+	ext.AdditionalDomains = []string{"t1", "t2"}
+
+	assert.True(t, ext.withDefaults(false), "withDefaults() returned false when the additionalDomains field needs to be removed")
+	assert.ElementsMatch(t, []string{"t1", "t2"}, ext.AdditionalDomainNames, "The values are the same between additionalDomains and additionalDomainNames, so nothing should be changed in additionalDomainNames")
+	assert.Nil(t, ext.AdditionalDomains, "The additionalDomains field was not set to nil")
+
+	ext.AdditionalDomains = []string{"t1", "t2", "t3"}
+
+	assert.True(t, ext.withDefaults(false), "withDefaults() returned false when the additionalDomains field needs to be removed")
+	assert.ElementsMatch(t, []string{"t1", "t2", "t3"}, ext.AdditionalDomainNames, "The unique values from additionalDomains were not appended to additionalDomainNames")
+	assert.Nil(t, ext.AdditionalDomains, "The additionalDomains field was not set to nil")
+
+	ext.AdditionalDomains = []string{"t1", "t3"}
+
+	assert.True(t, ext.withDefaults(false), "withDefaults() returned false when the additionalDomains field needs to be removed")
+	assert.ElementsMatch(t, []string{"t1", "t2", "t3"}, ext.AdditionalDomainNames, "The unique values from additionalDomains were not appended to additionalDomainNames")
+	assert.Nil(t, ext.AdditionalDomains, "The additionalDomains field was not set to nil")
+
+	ext.AdditionalDomains = []string{"t3"}
+
+	assert.True(t, ext.withDefaults(false), "withDefaults() returned false when the additionalDomains field needs to be removed")
+	assert.ElementsMatch(t, []string{"t1", "t2", "t3"}, ext.AdditionalDomainNames, "The unique values from additionalDomains were not appended to additionalDomainNames")
+	assert.Nil(t, ext.AdditionalDomains, "The additionalDomains field was not set to nil")
+
+	ext.AdditionalDomains = []string{"t4", "t1", "t2", "t3"}
+
+	assert.True(t, ext.withDefaults(false), "withDefaults() returned false when the additionalDomains field needs to be removed")
+	assert.ElementsMatch(t, []string{"t1", "t2", "t4", "t3"}, ext.AdditionalDomainNames, "The unique values from additionalDomains were not appended to additionalDomainNames")
+	assert.Nil(t, ext.AdditionalDomains, "The additionalDomains field was not set to nil")
+
+	ext.AdditionalDomainNames = nil
+	ext.AdditionalDomains = []string{"t4", "t1", "t2", "t3"}
+
+	assert.True(t, ext.withDefaults(false), "withDefaults() returned false when the additionalDomains field needs to be removed")
+	assert.ElementsMatch(t, []string{"t4", "t1", "t2", "t3"}, ext.AdditionalDomainNames, "The unique values from additionalDomains were not appended to additionalDomainNames")
+	assert.Nil(t, ext.AdditionalDomains, "The additionalDomains field was not set to nil")
+
+	ext.AdditionalDomainNames = []string{}
+	ext.AdditionalDomains = []string{"t4", "t1", "t2", "t3"}
+
+	assert.True(t, ext.withDefaults(false), "withDefaults() returned false when the additionalDomains field needs to be removed")
+	assert.ElementsMatch(t, []string{"t4", "t1", "t2", "t3"}, ext.AdditionalDomainNames, "The unique values from additionalDomains were not appended to additionalDomainNames")
+	assert.Nil(t, ext.AdditionalDomains, "The additionalDomains field was not set to nil")
+}
diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go
index 6d99a33..083c850 100644
--- a/api/v1beta1/zz_generated.deepcopy.go
+++ b/api/v1beta1/zz_generated.deepcopy.go
@@ -286,6 +286,11 @@ func (in *ExternalAddressability) DeepCopyInto(out *ExternalAddressability) {
 		*out = make([]string, len(*in))
 		copy(*out, *in)
 	}
+	if in.AdditionalDomains != nil {
+		in, out := &in.AdditionalDomains, &out.AdditionalDomains
+		*out = make([]string, len(*in))
+		copy(*out, *in)
+	}
 }
 
 // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ExternalAddressability.
diff --git a/config/crd/bases/solr.apache.org_solrclouds.yaml b/config/crd/bases/solr.apache.org_solrclouds.yaml
index 76b4d2a..6f1ca47 100644
--- a/config/crd/bases/solr.apache.org_solrclouds.yaml
+++ b/config/crd/bases/solr.apache.org_solrclouds.yaml
@@ -5723,11 +5723,16 @@ spec:
                   external:
                     description: External defines the way in which this SolrCloud nodes should be made addressable externally, from outside the Kubernetes cluster. If none is provided, the Solr Cloud will not be made addressable externally.
                     properties:
-                      additionalDomains:
+                      additionalDomainNames:
                         description: Provide additional domainNames that the Ingress or ExternalDNS should listen on. This option is ignored with the LoadBalancer method.
                         items:
                           type: string
                         type: array
+                      additionalDomains:
+                        description: "Provide additional domainNames that the Ingress or ExternalDNS should listen on. This option is ignored with the LoadBalancer method. \n DEPRECATED: Please use additionalDomainNames instead. This will be removed in a future version."
+                        items:
+                          type: string
+                        type: array
                       domainName:
                         description: "Override the domainName provided as startup parameters to the operator, used by ingresses and externalDNS. The common and/or node services will be addressable by unique names under the given domain. e.g. given.domain.name.com -> default-example-solrcloud.given.domain.name.com \n For the LoadBalancer method, this field is optional and will only be used when useExternalAddress=true. If used with the LoadBalancer method, you will need DNS routing to the [...]
                         type: string
diff --git a/docs/upgrade-notes.md b/docs/upgrade-notes.md
index e3f10c1..3465d56 100644
--- a/docs/upgrade-notes.md
+++ b/docs/upgrade-notes.md
@@ -116,6 +116,10 @@ _Note that the Helm chart version does not contain a `v` prefix, which the downl
   Please refer to the [Zookeeper Operator release notes](https://github.com/pravega/zookeeper-operator/releases) before upgrading.
   Make sure to install the correct version of the Zookeeper Operator CRDS, as [shown above](#upgrading-the-zookeeper-operator).
 
+- The SolrCloud CRD field `Spec.solrAddressability.external.additionalDomains` has been renamed to `additionalDomainNames`.
+  In this release `additionalDomains` is still accepted, but all values will automatically be added to `additionalDomainNames` and the field will be set to `nil` by the operator.
+  The `additionalDomains` option will be removed in a future version.
+
 ### v0.5.0
 - Due to the deprecation and removal of `networking.k8s.io/v1beta1` in Kubernetes v1.22, `networking.k8s.io/v1` will be used for Ingresses.
 
diff --git a/helm/solr-operator/Chart.yaml b/helm/solr-operator/Chart.yaml
index 7b3f4e1..5cac803 100644
--- a/helm/solr-operator/Chart.yaml
+++ b/helm/solr-operator/Chart.yaml
@@ -105,6 +105,13 @@ annotations:
           url: https://github.com/apache/solr-operator/issues/407
         - name: Github PR
           url: https://github.com/apache/solr-operator/pull/408
+    - kind: changed
+      description: The "addressability.external.additionalDomains" option has been renamed to "addressability.external.additionalDomainNames". See the upgrade notes for more information.
+      links:
+        - name: Github Issue
+          url: https://github.com/apache/solr-operator/issues/412
+        - name: Github PR
+          url: https://github.com/apache/solr-operator/pull/416
   artifacthub.io/images: |
     - name: solr-operator
       image: apache/solr-operator:v0.6.0-prerelease
diff --git a/helm/solr-operator/crds/crds.yaml b/helm/solr-operator/crds/crds.yaml
index 4ba9c51..94117ca 100644
--- a/helm/solr-operator/crds/crds.yaml
+++ b/helm/solr-operator/crds/crds.yaml
@@ -6978,11 +6978,16 @@ spec:
                   external:
                     description: External defines the way in which this SolrCloud nodes should be made addressable externally, from outside the Kubernetes cluster. If none is provided, the Solr Cloud will not be made addressable externally.
                     properties:
-                      additionalDomains:
+                      additionalDomainNames:
                         description: Provide additional domainNames that the Ingress or ExternalDNS should listen on. This option is ignored with the LoadBalancer method.
                         items:
                           type: string
                         type: array
+                      additionalDomains:
+                        description: "Provide additional domainNames that the Ingress or ExternalDNS should listen on. This option is ignored with the LoadBalancer method. \n DEPRECATED: Please use additionalDomainNames instead. This will be removed in a future version."
+                        items:
+                          type: string
+                        type: array
                       domainName:
                         description: "Override the domainName provided as startup parameters to the operator, used by ingresses and externalDNS. The common and/or node services will be addressable by unique names under the given domain. e.g. given.domain.name.com -> default-example-solrcloud.given.domain.name.com \n For the LoadBalancer method, this field is optional and will only be used when useExternalAddress=true. If used with the LoadBalancer method, you will need DNS routing to the [...]
                         type: string
diff --git a/helm/solr/Chart.yaml b/helm/solr/Chart.yaml
index 1726f08..aa08b84 100644
--- a/helm/solr/Chart.yaml
+++ b/helm/solr/Chart.yaml
@@ -54,6 +54,13 @@ annotations:
           url: https://github.com/apache/solr-operator/issues/379
         - name: Github PR
           url: https://github.com/apache/solr-operator/pull/380
+    - kind: changed
+      description: The "addressability.external.additionalDomains" option has been renamed to "addressability.external.additionalDomainNames". See the upgrade notes for more information.
+      links:
+        - name: Github Issue
+          url: https://github.com/apache/solr-operator/issues/412
+        - name: Github PR
+          url: https://github.com/apache/solr-operator/pull/416
   artifacthub.io/containsSecurityUpdates: "false"
   artifacthub.io/recommendations: |
     - url: https://artifacthub.io/packages/helm/apache-solr/solr-operator