Files
my-rook-config/pkg/operator/ceph/config/livenessprobe_test.go
T
Sébastien Han ccb52b84e6 ceph: configurable status checks and livenessprobe
This commit allows us to configure status check for each daemon:

* "mon": health check on the ceph monitors (quorum)
* "osd": health check on the ceph osds
* "status": ceph health status check

Each check is controlled by the following settings:

* disabled: whether to disable the check (default: false)
* internal: interval to run the check
* timeout: only valid for mons, is the timeout for unresponsive mon
before failling over.

Example to disable the status health check:

```yaml
healthCheck:
  daemonHealth:
    status:
      disabled: true
```

As part of that, pod's livenessprobe can now be configured via the
following settings:

* disabled: whether to enable or not
* probe: override the current probe in place by a new one

```yaml
healthCheck:
  livenessProbe:
    mon:
      disabled: true
```

Closes: https://github.com/rook/rook/issues/5772
Signed-off-by: Sébastien Han <seb@redhat.com>
2020-07-10 19:21:59 +02:00

63 lines
1.9 KiB
Go

/*
Copyright 2020 The Rook Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package config allows a ceph config file to be stored in Kubernetes and mounted as volumes into
// Ceph daemon containers.
package config
import (
"reflect"
"testing"
cephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
rookv1 "github.com/rook/rook/pkg/apis/rook.io/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/intstr"
)
func TestConfigureLivenessProbe(t *testing.T) {
p := &v1.Probe{
Handler: v1.Handler{
HTTPGet: &v1.HTTPGetAction{
Path: "/",
Port: intstr.FromInt(8080),
},
},
}
container := v1.Container{LivenessProbe: p}
l := map[rookv1.KeyType]*rookv1.ProbeSpec{cephv1.KeyMon: {Disabled: true}}
type args struct {
daemon rookv1.KeyType
container v1.Container
healthCheck cephv1.CephClusterHealthCheckSpec
}
tests := []struct {
name string
args args
want v1.Container
}{
{"probe-enabled", args{cephv1.KeyMon, container, cephv1.CephClusterHealthCheckSpec{}}, container},
{"probe-disabled", args{cephv1.KeyMon, container, cephv1.CephClusterHealthCheckSpec{LivenessProbe: l}}, v1.Container{}},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := ConfigureLivenessProbe(tt.args.daemon, tt.args.container, tt.args.healthCheck); !reflect.DeepEqual(got, tt.want) {
t.Errorf("ConfigureLivenessProbe() = %v, want %v", got, tt.want)
}
})
}
}