You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2021/02/08 16:42:10 UTC
[lucene-solr-operator] branch main updated: Add TCP Port support
for custom probes. (#210)
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/lucene-solr-operator.git
The following commit(s) were added to refs/heads/main by this push:
new d3e4891 Add TCP Port support for custom probes. (#210)
d3e4891 is described below
commit d3e489155644f831cfe83ad9c2420e23770ef2aa
Author: Houston Putman <ho...@apache.org>
AuthorDate: Mon Feb 8 11:42:01 2021 -0500
Add TCP Port support for custom probes. (#210)
Fix various test reconcile waits.
---
controllers/controller_utils_test.go | 6 ++----
controllers/solrcloud_controller.go | 26 ++++++++++++------------
controllers/solrcloud_controller_ingress_test.go | 12 +++++------
controllers/util/solr_util.go | 26 ++++++++++++------------
4 files changed, 34 insertions(+), 36 deletions(-)
diff --git a/controllers/controller_utils_test.go b/controllers/controller_utils_test.go
index aa8ac0d..0b80786 100644
--- a/controllers/controller_utils_test.go
+++ b/controllers/controller_utils_test.go
@@ -498,10 +498,8 @@ var (
FailureThreshold: 3,
PeriodSeconds: 5,
Handler: corev1.Handler{
- HTTPGet: &corev1.HTTPGetAction{
- Scheme: corev1.URISchemeHTTP,
- Path: "/solr/admin/info/system",
- Port: intstr.FromInt(8983),
+ TCPSocket: &corev1.TCPSocketAction{
+ Port: intstr.FromInt(8983),
},
},
}
diff --git a/controllers/solrcloud_controller.go b/controllers/solrcloud_controller.go
index 53b0d39..bcb796b 100644
--- a/controllers/solrcloud_controller.go
+++ b/controllers/solrcloud_controller.go
@@ -613,19 +613,19 @@ func reconcileZk(r *SolrCloudReconciler, logger logr.Logger, instance *solr.Solr
zkLogger.Info("Updating Zookeeer Cluster")
err = r.Update(context.TODO(), foundZkCluster)
}
- external := &foundZkCluster.Status.ExternalClientEndpoint
- if "" == *external {
- external = nil
- }
- internal := make([]string, zkCluster.Spec.Replicas)
- for i := range internal {
- internal[i] = fmt.Sprintf("%s-%d.%s-headless.%s:%d", foundZkCluster.Name, i, foundZkCluster.Name, foundZkCluster.Namespace, foundZkCluster.ZookeeperPorts().Client)
- }
- newStatus.ZookeeperConnectionInfo = solr.ZookeeperConnectionInfo{
- InternalConnectionString: strings.Join(internal, ","),
- ExternalConnectionString: external,
- ChRoot: pzk.ChRoot,
- }
+ }
+ external := &foundZkCluster.Status.ExternalClientEndpoint
+ if "" == *external {
+ external = nil
+ }
+ internal := make([]string, zkCluster.Spec.Replicas)
+ for i := range internal {
+ internal[i] = fmt.Sprintf("%s-%d.%s-headless.%s:%d", zkCluster.Name, i, zkCluster.Name, zkCluster.Namespace, zkCluster.ZookeeperPorts().Client)
+ }
+ newStatus.ZookeeperConnectionInfo = solr.ZookeeperConnectionInfo{
+ InternalConnectionString: strings.Join(internal, ","),
+ ExternalConnectionString: external,
+ ChRoot: pzk.ChRoot,
}
return err
} else {
diff --git a/controllers/solrcloud_controller_ingress_test.go b/controllers/solrcloud_controller_ingress_test.go
index 25fb416..1055d3a 100644
--- a/controllers/solrcloud_controller_ingress_test.go
+++ b/controllers/solrcloud_controller_ingress_test.go
@@ -109,6 +109,7 @@ func TestIngressCloudReconcile(t *testing.T) {
// Add an additional check for reconcile, so that the services will have IP addresses for the hostAliases to use
// Otherwise the reconciler will have 'blockReconciliationOfStatefulSet' set to true, and the stateful set will not be created
g.Eventually(requests, timeout).Should(gomega.Receive(gomega.Equal(expectedCloudRequest)))
+ g.Eventually(requests, timeout).Should(gomega.Receive(gomega.Equal(expectedCloudRequest)))
// Check the statefulSet
statefulSet := expectStatefulSet(t, g, requests, expectedCloudRequest, cloudSsKey)
@@ -239,8 +240,7 @@ func TestIngressNoNodesCloudReconcile(t *testing.T) {
g.Expect(err).NotTo(gomega.HaveOccurred())
defer testClient.Delete(context.TODO(), instance)
g.Eventually(requests, timeout).Should(gomega.Receive(gomega.Equal(expectedCloudRequest)))
- // Add an additional check for reconcile, so that the services will have IP addresses for the hostAliases to use
- // Otherwise the reconciler will have 'blockReconciliationOfStatefulSet' set to true, and the stateful set will not be created
+ // The default value of UseExternalAddress needs to be set to False
g.Eventually(requests, timeout).Should(gomega.Receive(gomega.Equal(expectedCloudRequest)))
g.Eventually(requests, timeout).Should(gomega.Receive(gomega.Equal(expectedCloudRequest)))
@@ -371,6 +371,7 @@ func TestIngressNoCommonCloudReconcile(t *testing.T) {
// Add an additional check for reconcile, so that the services will have IP addresses for the hostAliases to use
// Otherwise the reconciler will have 'blockReconciliationOfStatefulSet' set to true, and the stateful set will not be created
g.Eventually(requests, timeout).Should(gomega.Receive(gomega.Equal(expectedCloudRequest)))
+ g.Eventually(requests, timeout).Should(gomega.Receive(gomega.Equal(expectedCloudRequest)))
// Check the statefulSet
statefulSet := expectStatefulSet(t, g, requests, expectedCloudRequest, cloudSsKey)
@@ -499,8 +500,7 @@ func TestIngressUseInternalAddressCloudReconcile(t *testing.T) {
g.Expect(err).NotTo(gomega.HaveOccurred())
defer testClient.Delete(context.TODO(), instance)
g.Eventually(requests, timeout).Should(gomega.Receive(gomega.Equal(expectedCloudRequest)))
- // Add an additional check for reconcile, so that the services will have IP addresses for the hostAliases to use
- // Otherwise the reconciler will have 'blockReconciliationOfStatefulSet' set to true, and the stateful set will not be created
+ // Additional reconcile for defaulting of Spec
g.Eventually(requests, timeout).Should(gomega.Receive(gomega.Equal(expectedCloudRequest)))
// Check the statefulSet
@@ -633,6 +633,7 @@ func TestIngressExtraDomainsCloudReconcile(t *testing.T) {
// Otherwise the reconciler will have 'blockReconciliationOfStatefulSet' set to true, and the stateful set will not be created
g.Eventually(requests, timeout).Should(gomega.Receive(gomega.Equal(expectedCloudRequest)))
g.Eventually(requests, timeout).Should(gomega.Receive(gomega.Equal(expectedCloudRequest)))
+ g.Eventually(requests, timeout).Should(gomega.Receive(gomega.Equal(expectedCloudRequest)))
// Check the statefulSet
statefulSet := expectStatefulSet(t, g, requests, expectedCloudRequest, cloudSsKey)
@@ -762,8 +763,7 @@ func TestIngressKubeDomainCloudReconcile(t *testing.T) {
g.Expect(err).NotTo(gomega.HaveOccurred())
defer testClient.Delete(context.TODO(), instance)
g.Eventually(requests, timeout).Should(gomega.Receive(gomega.Equal(expectedCloudRequest)))
- // Add an additional check for reconcile, so that the services will have IP addresses for the hostAliases to use
- // Otherwise the reconciler will have 'blockReconciliationOfStatefulSet' set to true, and the stateful set will not be created
+ // Additional reconcile for defaulting of Spec
g.Eventually(requests, timeout).Should(gomega.Receive(gomega.Equal(expectedCloudRequest)))
g.Eventually(requests, timeout).Should(gomega.Receive(gomega.Equal(expectedCloudRequest)))
diff --git a/controllers/util/solr_util.go b/controllers/util/solr_util.go
index 74c4ce4..e124048 100644
--- a/controllers/util/solr_util.go
+++ b/controllers/util/solr_util.go
@@ -657,7 +657,7 @@ func GenerateConfigMap(solrCloud *solr.SolrCloud) *corev1.ConfigMap {
}
// fillProbe builds the probe logic used for pod liveness, readiness, startup checks
-func fillProbe(customSolrKubeOptions corev1.Probe, defaultInitialDelaySeconds int32, defaultTimeoutSeconds int32, defaultSuccessThreshold int32, defaultFailureThreshold int32, defaultPeriodSeconds int32, defaultHandler *corev1.Handler) *corev1.Probe {
+func fillProbe(customProbe corev1.Probe, defaultInitialDelaySeconds int32, defaultTimeoutSeconds int32, defaultSuccessThreshold int32, defaultFailureThreshold int32, defaultPeriodSeconds int32, defaultHandler *corev1.Handler) *corev1.Probe {
probe := &corev1.Probe{
InitialDelaySeconds: defaultInitialDelaySeconds,
TimeoutSeconds: defaultTimeoutSeconds,
@@ -667,28 +667,28 @@ func fillProbe(customSolrKubeOptions corev1.Probe, defaultInitialDelaySeconds in
Handler: *defaultHandler,
}
- if customSolrKubeOptions.InitialDelaySeconds != 0 {
- probe.InitialDelaySeconds = customSolrKubeOptions.InitialDelaySeconds
+ if customProbe.InitialDelaySeconds != 0 {
+ probe.InitialDelaySeconds = customProbe.InitialDelaySeconds
}
- if customSolrKubeOptions.TimeoutSeconds != 0 {
- probe.TimeoutSeconds = customSolrKubeOptions.TimeoutSeconds
+ if customProbe.TimeoutSeconds != 0 {
+ probe.TimeoutSeconds = customProbe.TimeoutSeconds
}
- if customSolrKubeOptions.SuccessThreshold != 0 {
- probe.SuccessThreshold = customSolrKubeOptions.SuccessThreshold
+ if customProbe.SuccessThreshold != 0 {
+ probe.SuccessThreshold = customProbe.SuccessThreshold
}
- if customSolrKubeOptions.FailureThreshold != 0 {
- probe.FailureThreshold = customSolrKubeOptions.FailureThreshold
+ if customProbe.FailureThreshold != 0 {
+ probe.FailureThreshold = customProbe.FailureThreshold
}
- if customSolrKubeOptions.PeriodSeconds != 0 {
- probe.PeriodSeconds = customSolrKubeOptions.PeriodSeconds
+ if customProbe.PeriodSeconds != 0 {
+ probe.PeriodSeconds = customProbe.PeriodSeconds
}
- if customSolrKubeOptions.Handler.Exec != nil || customSolrKubeOptions.Handler.HTTPGet != nil {
- probe.Handler = customSolrKubeOptions.Handler
+ if customProbe.Handler.Exec != nil || customProbe.Handler.HTTPGet != nil || customProbe.Handler.TCPSocket != nil {
+ probe.Handler = customProbe.Handler
}
return probe