Skip to content

Commit 46b6603

Browse files
authored
Merge pull request #361 from arangodb/feature/disable-probes
Allow to disable probes
2 parents ec1f360 + c577773 commit 46b6603

File tree

6 files changed

+113
-8
lines changed

6 files changed

+113
-8
lines changed

docs/Manual/Deployment/Kubernetes/DeploymentResource.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,14 @@ for each server of this group.
401401
This setting is not available for group `coordinators`, `syncmasters` & `syncworkers`
402402
because servers in these groups do not need persistent storage.
403403

404+
### `spec.<group>.probes.livenessProbeDisabled: bool`
405+
406+
If set to true, the operator does not generate a liveness probe for new pods belonging to this group.
407+
408+
### `spec.<group>.probes.readinessProbeDisabled: bool`
409+
410+
If set to true, the operator does not generate a readiness probe for new pods belonging to this group.
411+
404412
### `spec.<group>.tolerations: []Toleration`
405413

406414
This setting specifies the `tolerations` for the `Pod`s created

pkg/apis/deployment/v1alpha/server_group_spec.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,40 @@ type ServerGroupSpec struct {
5656
ServiceAccountName *string `json:"serviceAccountName,omitempty"`
5757
// NodeSelector speficies a set of selectors for nodes
5858
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
59+
// Probes specifies additional behaviour for probes
60+
Probes *ServerGroupProbesSpec `json:"probes,omitempty"`
61+
}
62+
63+
// ServerGroupProbesSpec contains specification for probes for pods of the server group
64+
type ServerGroupProbesSpec struct {
65+
// LivenessProbeDisabled if true livenessProbes are disabled
66+
LivenessProbeDisabled *bool `json:"livenessProbeDisabled,omitempty"`
67+
// LivenessProbeDisabled if specified the given probes is used as liveness probe
68+
//LivenessProbeOverride *v1.Probe `json:"LivenessProbeOverride,omitempty"`
69+
// LivenessProbeDisabled if true readinessProbes are disabled
70+
ReadinessProbeDisabled *bool `json:"ReadinessProbeDisabled,omitempty"`
71+
// ReadinessProbeOverride if specified the given probes is used as readiness probe
72+
//ReadinessProbeOverride *v1.Probe `json:"ReadinessProbeOverride,omitempty"`
73+
}
74+
75+
// // HasLivenessProbeOverride returns true if a livenessprobe override is set
76+
// func (s ServerGroupProbesSpec) HasLivenessProbeOverride() bool {
77+
// return s.LivenessProbeOverride != nil
78+
// }
79+
80+
// // HasReadinessProbeOverride returns true if a readinessprobe override is set
81+
// func (s ServerGroupProbesSpec) HasReadinessProbeOverride() bool {
82+
// return s.ReadinessProbeOverride != nil
83+
// }
84+
85+
// IsLivenessProbeDisabled returns true if liveness probes are disabled
86+
func (s ServerGroupProbesSpec) IsLivenessProbeDisabled() bool {
87+
return util.BoolOrDefault(s.LivenessProbeDisabled)
88+
}
89+
90+
// IsReadinessProbeDisabled returns true if readiness probes are disabled
91+
func (s ServerGroupProbesSpec) IsReadinessProbeDisabled() bool {
92+
return util.BoolOrDefault(s.ReadinessProbeDisabled)
5993
}
6094

6195
// GetCount returns the value of count.
@@ -98,6 +132,19 @@ func (s ServerGroupSpec) GetServiceAccountName() string {
98132
return util.StringOrDefault(s.ServiceAccountName)
99133
}
100134

135+
// HasProbesSpec returns true if Probes is non nil
136+
func (s ServerGroupSpec) HasProbesSpec() bool {
137+
return s.Probes != nil
138+
}
139+
140+
// GetProbesSpec returns the Probes spec or the nil value if not set
141+
func (s ServerGroupSpec) GetProbesSpec() ServerGroupProbesSpec {
142+
if s.HasProbesSpec() {
143+
return *s.Probes
144+
}
145+
return ServerGroupProbesSpec{}
146+
}
147+
101148
// Validate the given group spec
102149
func (s ServerGroupSpec) Validate(group ServerGroup, used bool, mode DeploymentMode, env Environment) error {
103150
if used {

pkg/apis/deployment/v1alpha/zz_generated.deepcopy.go

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/deployment/resources/pod_creator.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,15 @@ func createArangoSyncArgs(apiObject metav1.Object, spec api.DeploymentSpec, grou
331331

332332
// createLivenessProbe creates configuration for a liveness probe of a server in the given group.
333333
func (r *Resources) createLivenessProbe(spec api.DeploymentSpec, group api.ServerGroup) (*k8sutil.HTTPProbeConfig, error) {
334+
groupspec := spec.GetServerGroupSpec(group)
335+
336+
if groupspec.HasProbesSpec() {
337+
probesspec := groupspec.GetProbesSpec()
338+
if probesspec.IsLivenessProbeDisabled() {
339+
return nil, nil
340+
}
341+
}
342+
334343
switch group {
335344
case api.ServerGroupSingle, api.ServerGroupAgents, api.ServerGroupDBServers:
336345
authorization := ""
@@ -394,9 +403,19 @@ func (r *Resources) createLivenessProbe(spec api.DeploymentSpec, group api.Serve
394403

395404
// createReadinessProbe creates configuration for a readiness probe of a server in the given group.
396405
func (r *Resources) createReadinessProbe(spec api.DeploymentSpec, group api.ServerGroup, version driver.Version) (*k8sutil.HTTPProbeConfig, error) {
406+
groupspec := spec.GetServerGroupSpec(group)
407+
408+
if groupspec.HasProbesSpec() {
409+
probesspec := groupspec.GetProbesSpec()
410+
if probesspec.IsReadinessProbeDisabled() {
411+
return nil, nil
412+
}
413+
}
414+
397415
if group != api.ServerGroupSingle && group != api.ServerGroupCoordinators {
398416
return nil, nil
399417
}
418+
400419
authorization := ""
401420
if spec.IsAuthenticated() {
402421
secretData, err := r.getJWTSecret(spec)

pkg/util/k8sutil/probes.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ func (config HTTPProbeConfig) Create() *v1.Probe {
7777
HTTPHeaders: headers,
7878
},
7979
},
80-
InitialDelaySeconds: def(config.InitialDelaySeconds, 30), // Wait 30s before first probe
81-
TimeoutSeconds: def(config.TimeoutSeconds, 2), // Timeout of each probe is 2s
82-
PeriodSeconds: def(config.PeriodSeconds, 10), // Interval between probes is 10s
83-
SuccessThreshold: def(config.SuccessThreshold, 1), // Single probe is enough to indicate success
84-
FailureThreshold: def(config.FailureThreshold, 3), // Need 3 failed probes to consider a failed state
80+
InitialDelaySeconds: def(config.InitialDelaySeconds, 15*60), // Wait 15min before first probe
81+
TimeoutSeconds: def(config.TimeoutSeconds, 2), // Timeout of each probe is 2s
82+
PeriodSeconds: def(config.PeriodSeconds, 60), // Interval between probes is 10s
83+
SuccessThreshold: def(config.SuccessThreshold, 1), // Single probe is enough to indicate success
84+
FailureThreshold: def(config.FailureThreshold, 10), // Need 10 failed probes to consider a failed state
8585
}
8686
}

pkg/util/k8sutil/probes_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ func TestCreate(t *testing.T) {
3737
config := HTTPProbeConfig{path, false, secret, 0, 0, 0, 0, 0, 0}
3838
probe := config.Create()
3939

40-
assert.Equal(t, probe.InitialDelaySeconds, int32(30))
40+
assert.Equal(t, probe.InitialDelaySeconds, int32(15*60))
4141
assert.Equal(t, probe.TimeoutSeconds, int32(2))
42-
assert.Equal(t, probe.PeriodSeconds, int32(10))
42+
assert.Equal(t, probe.PeriodSeconds, int32(60))
4343
assert.Equal(t, probe.SuccessThreshold, int32(1))
44-
assert.Equal(t, probe.FailureThreshold, int32(3))
44+
assert.Equal(t, probe.FailureThreshold, int32(10))
4545

4646
assert.Equal(t, probe.Handler.HTTPGet.Path, path)
4747
assert.Equal(t, probe.Handler.HTTPGet.HTTPHeaders[0].Name, "Authorization")

0 commit comments

Comments
 (0)