Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/Manual/Deployment/Kubernetes/DeploymentResource.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,14 @@ for each server of this group.
This setting is not available for group `coordinators`, `syncmasters` & `syncworkers`
because servers in these groups do not need persistent storage.

### `spec.<group>.probes.livenessProbeDisabled: bool`

If set to true, the operator does not generate a liveness probe for new pods belonging to this group.

### `spec.<group>.probes.readinessProbeDisabled: bool`

If set to true, the operator does not generate a readiness probe for new pods belonging to this group.

### `spec.<group>.tolerations: []Toleration`

This setting specifies the `tolerations` for the `Pod`s created
Expand Down
47 changes: 47 additions & 0 deletions pkg/apis/deployment/v1alpha/server_group_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,40 @@ type ServerGroupSpec struct {
ServiceAccountName *string `json:"serviceAccountName,omitempty"`
// NodeSelector speficies a set of selectors for nodes
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
// Probes specifies additional behaviour for probes
Probes *ServerGroupProbesSpec `json:"probes,omitempty"`
}

// ServerGroupProbesSpec contains specification for probes for pods of the server group
type ServerGroupProbesSpec struct {
// LivenessProbeDisabled if true livenessProbes are disabled
LivenessProbeDisabled *bool `json:"livenessProbeDisabled,omitempty"`
// LivenessProbeDisabled if specified the given probes is used as liveness probe
//LivenessProbeOverride *v1.Probe `json:"LivenessProbeOverride,omitempty"`
// LivenessProbeDisabled if true readinessProbes are disabled
ReadinessProbeDisabled *bool `json:"ReadinessProbeDisabled,omitempty"`
// ReadinessProbeOverride if specified the given probes is used as readiness probe
//ReadinessProbeOverride *v1.Probe `json:"ReadinessProbeOverride,omitempty"`
}

// // HasLivenessProbeOverride returns true if a livenessprobe override is set
// func (s ServerGroupProbesSpec) HasLivenessProbeOverride() bool {
// return s.LivenessProbeOverride != nil
// }

// // HasReadinessProbeOverride returns true if a readinessprobe override is set
// func (s ServerGroupProbesSpec) HasReadinessProbeOverride() bool {
// return s.ReadinessProbeOverride != nil
// }

// IsLivenessProbeDisabled returns true if liveness probes are disabled
func (s ServerGroupProbesSpec) IsLivenessProbeDisabled() bool {
return util.BoolOrDefault(s.LivenessProbeDisabled)
}

// IsReadinessProbeDisabled returns true if readiness probes are disabled
func (s ServerGroupProbesSpec) IsReadinessProbeDisabled() bool {
return util.BoolOrDefault(s.ReadinessProbeDisabled)
}

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

// HasProbesSpec returns true if Probes is non nil
func (s ServerGroupSpec) HasProbesSpec() bool {
return s.Probes != nil
}

// GetProbesSpec returns the Probes spec or the nil value if not set
func (s ServerGroupSpec) GetProbesSpec() ServerGroupProbesSpec {
if s.HasProbesSpec() {
return *s.Probes
}
return ServerGroupProbesSpec{}
}

// Validate the given group spec
func (s ServerGroupSpec) Validate(group ServerGroup, used bool, mode DeploymentMode, env Environment) error {
if used {
Expand Down
31 changes: 31 additions & 0 deletions pkg/apis/deployment/v1alpha/zz_generated.deepcopy.go

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

19 changes: 19 additions & 0 deletions pkg/deployment/resources/pod_creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,15 @@ func createArangoSyncArgs(apiObject metav1.Object, spec api.DeploymentSpec, grou

// createLivenessProbe creates configuration for a liveness probe of a server in the given group.
func (r *Resources) createLivenessProbe(spec api.DeploymentSpec, group api.ServerGroup) (*k8sutil.HTTPProbeConfig, error) {
groupspec := spec.GetServerGroupSpec(group)

if groupspec.HasProbesSpec() {
probesspec := groupspec.GetProbesSpec()
if probesspec.IsLivenessProbeDisabled() {
return nil, nil
}
}

switch group {
case api.ServerGroupSingle, api.ServerGroupAgents, api.ServerGroupDBServers:
authorization := ""
Expand Down Expand Up @@ -394,9 +403,19 @@ func (r *Resources) createLivenessProbe(spec api.DeploymentSpec, group api.Serve

// createReadinessProbe creates configuration for a readiness probe of a server in the given group.
func (r *Resources) createReadinessProbe(spec api.DeploymentSpec, group api.ServerGroup, version driver.Version) (*k8sutil.HTTPProbeConfig, error) {
groupspec := spec.GetServerGroupSpec(group)

if groupspec.HasProbesSpec() {
probesspec := groupspec.GetProbesSpec()
if probesspec.IsReadinessProbeDisabled() {
return nil, nil
}
}

if group != api.ServerGroupSingle && group != api.ServerGroupCoordinators {
return nil, nil
}

authorization := ""
if spec.IsAuthenticated() {
secretData, err := r.getJWTSecret(spec)
Expand Down
10 changes: 5 additions & 5 deletions pkg/util/k8sutil/probes.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ func (config HTTPProbeConfig) Create() *v1.Probe {
HTTPHeaders: headers,
},
},
InitialDelaySeconds: def(config.InitialDelaySeconds, 30), // Wait 30s before first probe
TimeoutSeconds: def(config.TimeoutSeconds, 2), // Timeout of each probe is 2s
PeriodSeconds: def(config.PeriodSeconds, 10), // Interval between probes is 10s
SuccessThreshold: def(config.SuccessThreshold, 1), // Single probe is enough to indicate success
FailureThreshold: def(config.FailureThreshold, 3), // Need 3 failed probes to consider a failed state
InitialDelaySeconds: def(config.InitialDelaySeconds, 15*60), // Wait 15min before first probe
TimeoutSeconds: def(config.TimeoutSeconds, 2), // Timeout of each probe is 2s
PeriodSeconds: def(config.PeriodSeconds, 60), // Interval between probes is 10s
SuccessThreshold: def(config.SuccessThreshold, 1), // Single probe is enough to indicate success
FailureThreshold: def(config.FailureThreshold, 10), // Need 10 failed probes to consider a failed state
}
}
6 changes: 3 additions & 3 deletions pkg/util/k8sutil/probes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ func TestCreate(t *testing.T) {
config := HTTPProbeConfig{path, false, secret, 0, 0, 0, 0, 0, 0}
probe := config.Create()

assert.Equal(t, probe.InitialDelaySeconds, int32(30))
assert.Equal(t, probe.InitialDelaySeconds, int32(15*60))
assert.Equal(t, probe.TimeoutSeconds, int32(2))
assert.Equal(t, probe.PeriodSeconds, int32(10))
assert.Equal(t, probe.PeriodSeconds, int32(60))
assert.Equal(t, probe.SuccessThreshold, int32(1))
assert.Equal(t, probe.FailureThreshold, int32(3))
assert.Equal(t, probe.FailureThreshold, int32(10))

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