Skip to content

Commit

Permalink
Allow customization of ZK Probes (#546)
Browse files Browse the repository at this point in the history
  • Loading branch information
HoustonPutman authored Apr 12, 2023
1 parent a6c7965 commit 89d97d4
Show file tree
Hide file tree
Showing 11 changed files with 149 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/v1beta1/solrcloud_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package v1beta1

import (
"fmt"
"github.com/apache/solr-operator/controllers/zk_api"
"github.com/go-logr/logr"
"strconv"
"strings"
Expand Down Expand Up @@ -847,6 +848,11 @@ type ZookeeperSpec struct {
// Additional Zookeeper Configuration settings
// +optional
Config ZookeeperConfig `json:"config,omitempty"`

// Probes specifies the timeout values for the Readiness and Liveness Probes
// for the zookeeper pods.
// +optional
Probes *zk_api.Probes `json:"probes,omitempty"`
}

type ZKPersistence struct {
Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions config/crd/bases/solr.apache.org_solrclouds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10240,6 +10240,57 @@ spec:
type: string
type: object
type: object
probes:
description: Probes specifies the timeout values for the Readiness
and Liveness Probes for the zookeeper pods.
properties:
livenessProbe:
properties:
failureThreshold:
format: int32
minimum: 0
type: integer
initialDelaySeconds:
format: int32
minimum: 0
type: integer
periodSeconds:
format: int32
minimum: 0
type: integer
successThreshold:
format: int32
minimum: 0
type: integer
timeoutSeconds:
format: int32
minimum: 0
type: integer
type: object
readinessProbe:
properties:
failureThreshold:
format: int32
minimum: 0
type: integer
initialDelaySeconds:
format: int32
minimum: 0
type: integer
periodSeconds:
format: int32
minimum: 0
type: integer
successThreshold:
format: int32
minimum: 0
type: integer
timeoutSeconds:
format: int32
minimum: 0
type: integer
type: object
type: object
readOnlyAcl:
description: ZooKeeper ACL to use when connecting with ZK
for reading operations. This ACL should have READ permission
Expand Down
14 changes: 14 additions & 0 deletions controllers/controller_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1005,4 +1005,18 @@ var (
testIngressClass = "test-ingress-class"
testSolrZKOpts = "-Dsolr.zk.opts=this"
testSolrOpts = "-Dsolr.opts=this"
testZkProbes = zk_api.Probes{
ReadinessProbe: &zk_api.Probe{
PeriodSeconds: 3,
SuccessThreshold: 5,
TimeoutSeconds: 10,
},
LivenessProbe: &zk_api.Probe{
InitialDelaySeconds: 6,
PeriodSeconds: 4,
FailureThreshold: 0,
SuccessThreshold: 3,
TimeoutSeconds: 0,
},
}
)
2 changes: 2 additions & 0 deletions controllers/solrcloud_controller_zk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ var _ = FDescribe("SolrCloud controller - Zookeeper", func() {
},
Config: zkConf,
ChRoot: "a-ch/root",
Probes: &testZkProbes,
},
},
CustomSolrKubeOptions: solrv1beta1.CustomSolrKubeOptions{
Expand Down Expand Up @@ -275,6 +276,7 @@ var _ = FDescribe("SolrCloud controller - Zookeeper", func() {
Expect(zkCluster.Spec.Ephemeral).To(Not(BeNil()), "ZkCluster.spec.ephemeral should not be nil")
Expect(zkCluster.Spec.Ephemeral.EmptyDirVolumeSource.Medium).To(BeEquivalentTo("Memory"), "Incorrect EmptyDir medium for ZK Cluster ephemeral storage")
Expect(zkCluster.Spec.Persistence).To(BeNil(), "ZkCluster.spec.persistence should be nil when using ephermeral storage")
Expect(zkCluster.Spec.Probes).To(Equal(&testZkProbes), "Incorrect zkCluster probes")

// Check ZK Pod Options
Expect(zkCluster.Spec.Pod.Affinity).To(Equal(testAffinity), "Incorrect zkCluster affinity")
Expand Down
4 changes: 4 additions & 0 deletions controllers/util/zk_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,10 @@ func GenerateZookeeperCluster(solrCloud *solrv1beta1.SolrCloud, zkSpec *solrv1be
}
}

if zkSpec.Probes != nil {
zkCluster.Spec.Probes = zkSpec.Probes
}

// Add defaults that the ZK Operator should set itself, otherwise we will have problems with reconcile loops.
// Also it will default the spec.Probes object which cannot be set to null.
// TODO: Might be able to remove when the following is resolved and the dependency is upgraded:
Expand Down
7 changes: 7 additions & 0 deletions helm/solr-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ annotations:
url: https://github.com/apache/solr-operator/issues/544
- name: GitHub PR
url: https://github.com/apache/solr-operator/pull/545
- kind: added
description: Support custom Zookeeper probes
links:
- name: GitHub Issue
url: https://github.com/apache/solr-operator/issues/477
- name: GitHub PR
url: https://github.com/apache/solr-operator/pull/546
artifacthub.io/images: |
- name: solr-operator
image: apache/solr-operator:v0.7.0-prerelease
Expand Down
51 changes: 51 additions & 0 deletions helm/solr-operator/crds/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10489,6 +10489,57 @@ spec:
type: string
type: object
type: object
probes:
description: Probes specifies the timeout values for the Readiness
and Liveness Probes for the zookeeper pods.
properties:
livenessProbe:
properties:
failureThreshold:
format: int32
minimum: 0
type: integer
initialDelaySeconds:
format: int32
minimum: 0
type: integer
periodSeconds:
format: int32
minimum: 0
type: integer
successThreshold:
format: int32
minimum: 0
type: integer
timeoutSeconds:
format: int32
minimum: 0
type: integer
type: object
readinessProbe:
properties:
failureThreshold:
format: int32
minimum: 0
type: integer
initialDelaySeconds:
format: int32
minimum: 0
type: integer
periodSeconds:
format: int32
minimum: 0
type: integer
successThreshold:
format: int32
minimum: 0
type: integer
timeoutSeconds:
format: int32
minimum: 0
type: integer
type: object
type: object
readOnlyAcl:
description: ZooKeeper ACL to use when connecting with ZK
for reading operations. This ACL should have READ permission
Expand Down
2 changes: 2 additions & 0 deletions helm/solr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ Currently the Zookeeper Operator does not support ACLs, so do not use the provid
| zk.provided.zookeeperPodPolicy.securityContext | object | | Security context for the entire ZooKeeper pod. More information can be found in the [Kubernetes docs](More info: https://kubernetes.io/docs/tasks/configure-pod-container/security-context). |
| zk.provided.zookeeperPodPolicy.terminationGracePeriodSeconds | int | `30` | The amount of time that Kubernetes will give for a zookeeper pod instance to shutdown normally. |
| zk.provided.zookeeperPodPolicy.imagePullSecrets | []object | | List of image pull secrets to inject into the Zookeeper pod. |
| zk.provided.probes.readinessProbe | object | | Override the default readinessProbe for Zookeeper Pods. |
| zk.provided.probes.livenessProbe | object | | Override the default livenessProbe for Zookeeper Pods. |
| zk.acl.secret | string | | Name of a secret in the same namespace as the Solr cloud that stores the ZK admin ACL information |
| zk.acl.usernameKey | string | | Key in the Admin ACL Secret that stores the ACL username |
| zk.acl.passwordKey | string | | Key in the Admin ACL Secret that stores the ACL password |
Expand Down
4 changes: 4 additions & 0 deletions helm/solr/templates/solrcloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,10 @@ spec:
zookeeperPodPolicy:
{{- include "solr.zk.zookeeperPodPolicy" . | nindent 8 }}
{{- end }}
{{- if .Values.zk.provided.probes }}
probes:
{{- toYaml .Values.zk.provided.probes | nindent 8 }}
{{- end }}
{{- if .Values.zk.acl }}
acl:
{{- toYaml .Values.zk.acl | nindent 8 }}
Expand Down
2 changes: 2 additions & 0 deletions helm/solr/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ zk:
# resources: {}
# # Set ZK service account individually instead of the global "serviceAccount.name"
# serviceAccountName: ""
# Override the default Zookeeper probes
probes: {}

# Storage defaults to the type of storage you use for Solr, which is ephemeral by default.
# Explicitly set the storage type, only necessary when wishing to use an empty persistence or ephemeral object.
Expand Down

0 comments on commit 89d97d4

Please sign in to comment.