From d8de013443e05a9c0174561dbd714832bb032d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Tue, 23 Mar 2021 18:03:42 +0100 Subject: [PATCH] ceph: use metav1.Duration for time CRD field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, `interval` was just a string so no special validation was done by the OpenAPI validator. Now that it is advertised as metav1.Duration the server will introspect it correctly. Underneath the type is still a string so no update issue to be worried about. Signed-off-by: Sébastien Han --- .../charts/rook-ceph/templates/resources.yaml | 11 +++++++ cluster/examples/kubernetes/ceph/crds.yaml | 22 ++++++++++++++ pkg/apis/ceph.rook.io/v1/types.go | 3 +- .../ceph.rook.io/v1/zz_generated.deepcopy.go | 20 ++++++++----- pkg/operator/ceph/cluster/cephstatus.go | 30 ++++++++----------- pkg/operator/ceph/cluster/cephstatus_test.go | 6 ++-- pkg/operator/ceph/cluster/mon/health.go | 8 ++--- pkg/operator/ceph/cluster/mon/health_test.go | 2 +- pkg/operator/ceph/cluster/osd/health.go | 14 ++++----- pkg/operator/ceph/cluster/osd/health_test.go | 4 +-- pkg/operator/ceph/object/health.go | 27 +++++++++-------- pkg/operator/ceph/pool/health.go | 16 +++++----- 12 files changed, 97 insertions(+), 66 deletions(-) diff --git a/cluster/charts/rook-ceph/templates/resources.yaml b/cluster/charts/rook-ceph/templates/resources.yaml index ff5058fcc..9eb5d7ef1 100644 --- a/cluster/charts/rook-ceph/templates/resources.yaml +++ b/cluster/charts/rook-ceph/templates/resources.yaml @@ -155,6 +155,7 @@ spec: disabled: type: boolean interval: + description: Interval is the internal in second or minute for the health check to run like 60s for 60 seconds type: string timeout: type: string @@ -557,6 +558,7 @@ spec: disabled: type: boolean interval: + description: Interval is the internal in second or minute for the health check to run like 60s for 60 seconds type: string timeout: type: string @@ -568,6 +570,7 @@ spec: disabled: type: boolean interval: + description: Interval is the internal in second or minute for the health check to run like 60s for 60 seconds type: string timeout: type: string @@ -579,6 +582,7 @@ spec: disabled: type: boolean interval: + description: Interval is the internal in second or minute for the health check to run like 60s for 60 seconds type: string timeout: type: string @@ -4777,6 +4781,7 @@ spec: disabled: type: boolean interval: + description: Interval is the internal in second or minute for the health check to run like 60s for 60 seconds type: string timeout: type: string @@ -4910,6 +4915,7 @@ spec: disabled: type: boolean interval: + description: Interval is the internal in second or minute for the health check to run like 60s for 60 seconds type: string timeout: type: string @@ -6192,6 +6198,7 @@ spec: disabled: type: boolean interval: + description: Interval is the internal in second or minute for the health check to run like 60s for 60 seconds type: string timeout: type: string @@ -6734,6 +6741,7 @@ spec: disabled: type: boolean interval: + description: Interval is the internal in second or minute for the health check to run like 60s for 60 seconds type: string timeout: type: string @@ -6956,6 +6964,7 @@ spec: disabled: type: boolean interval: + description: Interval is the internal in second or minute for the health check to run like 60s for 60 seconds type: string timeout: type: string @@ -7303,6 +7312,7 @@ spec: disabled: type: boolean interval: + description: Interval is the internal in second or minute for the health check to run like 60s for 60 seconds type: string timeout: type: string @@ -7435,6 +7445,7 @@ spec: disabled: type: boolean interval: + description: Interval is the internal in second or minute for the health check to run like 60s for 60 seconds type: string timeout: type: string diff --git a/cluster/examples/kubernetes/ceph/crds.yaml b/cluster/examples/kubernetes/ceph/crds.yaml index 68cc796e7..2f8fda066 100644 --- a/cluster/examples/kubernetes/ceph/crds.yaml +++ b/cluster/examples/kubernetes/ceph/crds.yaml @@ -178,6 +178,8 @@ spec: disabled: type: boolean interval: + description: Interval is the internal in second or minute + for the health check to run like 60s for 60 seconds type: string timeout: type: string @@ -628,6 +630,8 @@ spec: disabled: type: boolean interval: + description: Interval is the internal in second or minute + for the health check to run like 60s for 60 seconds type: string timeout: type: string @@ -640,6 +644,8 @@ spec: disabled: type: boolean interval: + description: Interval is the internal in second or minute + for the health check to run like 60s for 60 seconds type: string timeout: type: string @@ -652,6 +658,8 @@ spec: disabled: type: boolean interval: + description: Interval is the internal in second or minute + for the health check to run like 60s for 60 seconds type: string timeout: type: string @@ -7658,6 +7666,8 @@ spec: disabled: type: boolean interval: + description: Interval is the internal in second or minute + for the health check to run like 60s for 60 seconds type: string timeout: type: string @@ -7810,6 +7820,8 @@ spec: disabled: type: boolean interval: + description: Interval is the internal in second or minute + for the health check to run like 60s for 60 seconds type: string timeout: type: string @@ -9850,6 +9862,8 @@ spec: disabled: type: boolean interval: + description: Interval is the internal in second or minute + for the health check to run like 60s for 60 seconds type: string timeout: type: string @@ -10775,6 +10789,8 @@ spec: disabled: type: boolean interval: + description: Interval is the internal in second or minute + for the health check to run like 60s for 60 seconds type: string timeout: type: string @@ -11050,6 +11066,8 @@ spec: disabled: type: boolean interval: + description: Interval is the internal in second or minute + for the health check to run like 60s for 60 seconds type: string timeout: type: string @@ -11431,6 +11449,8 @@ spec: disabled: type: boolean interval: + description: Interval is the internal in second or minute + for the health check to run like 60s for 60 seconds type: string timeout: type: string @@ -11582,6 +11602,8 @@ spec: disabled: type: boolean interval: + description: Interval is the internal in second or minute + for the health check to run like 60s for 60 seconds type: string timeout: type: string diff --git a/pkg/apis/ceph.rook.io/v1/types.go b/pkg/apis/ceph.rook.io/v1/types.go index 55831c251..373ee817a 100755 --- a/pkg/apis/ceph.rook.io/v1/types.go +++ b/pkg/apis/ceph.rook.io/v1/types.go @@ -988,8 +988,9 @@ type BucketHealthCheckSpec struct { type HealthCheckSpec struct { // +optional Disabled bool `json:"disabled,omitempty"` + // Interval is the internal in second or minute for the health check to run like 60s for 60 seconds // +optional - Interval string `json:"interval,omitempty"` + Interval *metav1.Duration `json:"interval,omitempty"` // +optional Timeout string `json:"timeout,omitempty"` } diff --git a/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go b/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go index 883b5733a..2c356c403 100644 --- a/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go +++ b/pkg/apis/ceph.rook.io/v1/zz_generated.deepcopy.go @@ -23,13 +23,14 @@ package v1 import ( rookiov1 "github.com/rook/rook/pkg/apis/rook.io/v1" corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *BucketHealthCheckSpec) DeepCopyInto(out *BucketHealthCheckSpec) { *out = *in - out.Bucket = in.Bucket + in.Bucket.DeepCopyInto(&out.Bucket) if in.LivenessProbe != nil { in, out := &in.LivenessProbe, &out.LivenessProbe *out = new(rookiov1.ProbeSpec) @@ -302,7 +303,7 @@ func (in *CephCluster) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CephClusterHealthCheckSpec) DeepCopyInto(out *CephClusterHealthCheckSpec) { *out = *in - out.DaemonHealth = in.DaemonHealth + in.DaemonHealth.DeepCopyInto(&out.DaemonHealth) if in.LivenessProbe != nil { in, out := &in.LivenessProbe, &out.LivenessProbe *out = make(map[rookiov1.KeyType]*rookiov1.ProbeSpec, len(*in)) @@ -1242,9 +1243,9 @@ func (in *CrashCollectorSpec) DeepCopy() *CrashCollectorSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DaemonHealthSpec) DeepCopyInto(out *DaemonHealthSpec) { *out = *in - out.Status = in.Status - out.Monitor = in.Monitor - out.ObjectStorageDaemon = in.ObjectStorageDaemon + in.Status.DeepCopyInto(&out.Status) + in.Monitor.DeepCopyInto(&out.Monitor) + in.ObjectStorageDaemon.DeepCopyInto(&out.ObjectStorageDaemon) return } @@ -1502,6 +1503,11 @@ func (in *GatewaySpec) DeepCopy() *GatewaySpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HealthCheckSpec) DeepCopyInto(out *HealthCheckSpec) { *out = *in + if in.Interval != nil { + in, out := &in.Interval, &out.Interval + *out = new(metav1.Duration) + **out = **in + } return } @@ -1610,7 +1616,7 @@ func (in *MgrSpec) DeepCopy() *MgrSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MirrorHealthCheckSpec) DeepCopyInto(out *MirrorHealthCheckSpec) { *out = *in - out.Mirror = in.Mirror + in.Mirror.DeepCopyInto(&out.Mirror) return } @@ -2010,7 +2016,7 @@ func (in *PoolSpec) DeepCopyInto(out *PoolSpec) { } } in.Mirroring.DeepCopyInto(&out.Mirroring) - out.StatusCheck = in.StatusCheck + in.StatusCheck.DeepCopyInto(&out.StatusCheck) in.Quotas.DeepCopyInto(&out.Quotas) return } diff --git a/pkg/operator/ceph/cluster/cephstatus.go b/pkg/operator/ceph/cluster/cephstatus.go index c8b0508af..62f5b4c4c 100644 --- a/pkg/operator/ceph/cluster/cephstatus.go +++ b/pkg/operator/ceph/cluster/cephstatus.go @@ -37,7 +37,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) -const ( +var ( // defaultStatusCheckInterval is the interval to check the status of the ceph cluster defaultStatusCheckInterval = 60 * time.Second ) @@ -46,7 +46,7 @@ const ( type cephStatusChecker struct { context *clusterd.Context clusterInfo *cephclient.ClusterInfo - interval time.Duration + interval *time.Duration client client.Client isExternal bool } @@ -56,30 +56,26 @@ func newCephStatusChecker(context *clusterd.Context, clusterInfo *cephclient.Clu c := &cephStatusChecker{ context: context, clusterInfo: clusterInfo, - interval: defaultStatusCheckInterval, + interval: &defaultStatusCheckInterval, client: context.Client, isExternal: clusterSpec.External.Enable, } // allow overriding the check interval with an env var on the operator // Keep the existing behavior - var checkInterval string + var checkInterval *time.Duration checkIntervalCRSetting := clusterSpec.HealthCheck.DaemonHealth.Status.Interval checkIntervalEnv := os.Getenv("ROOK_CEPH_STATUS_CHECK_INTERVAL") if checkIntervalEnv != "" { - checkInterval = checkIntervalEnv - } - - if checkIntervalCRSetting != "" && checkIntervalEnv == "" { - checkInterval = checkIntervalCRSetting - } - - // Set duration - if checkInterval != "" { - if duration, err := time.ParseDuration(checkInterval); err == nil { - logger.Infof("ceph status check interval is %s", checkInterval) - c.interval = duration + if duration, err := time.ParseDuration(checkIntervalEnv); err == nil { + checkInterval = &duration } + } else if checkIntervalCRSetting != nil { + checkInterval = &checkIntervalCRSetting.Duration + } + if checkInterval != nil { + logger.Infof("ceph status check interval is %s", checkInterval.String()) + c.interval = checkInterval } return c @@ -96,7 +92,7 @@ func (c *cephStatusChecker) checkCephStatus(stopCh chan struct{}) { logger.Infof("stopping monitoring of ceph status") return - case <-time.After(c.interval): + case <-time.After(*c.interval): c.checkStatus() } } diff --git a/pkg/operator/ceph/cluster/cephstatus_test.go b/pkg/operator/ceph/cluster/cephstatus_test.go index f86d9fc7a..90f9e53ac 100644 --- a/pkg/operator/ceph/cluster/cephstatus_test.go +++ b/pkg/operator/ceph/cluster/cephstatus_test.go @@ -142,9 +142,9 @@ func TestNewCephStatusChecker(t *testing.T) { args args want *cephStatusChecker }{ - {"default-interval", args{c, clusterInfo, &cephv1.ClusterSpec{}}, &cephStatusChecker{c, clusterInfo, defaultStatusCheckInterval, c.Client, false}}, - {"10s-interval", args{c, clusterInfo, &cephv1.ClusterSpec{HealthCheck: cephv1.CephClusterHealthCheckSpec{DaemonHealth: cephv1.DaemonHealthSpec{Status: cephv1.HealthCheckSpec{Interval: "10s"}}}}}, &cephStatusChecker{c, clusterInfo, time10s, c.Client, false}}, - {"10s-interval-external", args{c, clusterInfo, &cephv1.ClusterSpec{External: cephv1.ExternalSpec{Enable: true}, HealthCheck: cephv1.CephClusterHealthCheckSpec{DaemonHealth: cephv1.DaemonHealthSpec{Status: cephv1.HealthCheckSpec{Interval: "10s"}}}}}, &cephStatusChecker{c, clusterInfo, time10s, c.Client, true}}, + {"default-interval", args{c, clusterInfo, &cephv1.ClusterSpec{}}, &cephStatusChecker{c, clusterInfo, &defaultStatusCheckInterval, c.Client, false}}, + {"10s-interval", args{c, clusterInfo, &cephv1.ClusterSpec{HealthCheck: cephv1.CephClusterHealthCheckSpec{DaemonHealth: cephv1.DaemonHealthSpec{Status: cephv1.HealthCheckSpec{Interval: &metav1.Duration{Duration: time10s}}}}}}, &cephStatusChecker{c, clusterInfo, &time10s, c.Client, false}}, + {"10s-interval-external", args{c, clusterInfo, &cephv1.ClusterSpec{External: cephv1.ExternalSpec{Enable: true}, HealthCheck: cephv1.CephClusterHealthCheckSpec{DaemonHealth: cephv1.DaemonHealthSpec{Status: cephv1.HealthCheckSpec{Interval: &metav1.Duration{Duration: time10s}}}}}}, &cephStatusChecker{c, clusterInfo, &time10s, c.Client, true}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/operator/ceph/cluster/mon/health.go b/pkg/operator/ceph/cluster/mon/health.go index 9fbe1dfff..447e932ea 100644 --- a/pkg/operator/ceph/cluster/mon/health.go +++ b/pkg/operator/ceph/cluster/mon/health.go @@ -61,11 +61,9 @@ func NewHealthChecker(monCluster *Cluster) *HealthChecker { checkInterval := monCluster.spec.HealthCheck.DaemonHealth.Monitor.Interval // allow overriding the check interval - if checkInterval != "" { - if duration, err := time.ParseDuration(checkInterval); err == nil { - logger.Infof("ceph mon status in namespace %q check interval %q", monCluster.Namespace, checkInterval) - h.interval = duration - } + if checkInterval != nil { + logger.Infof("ceph mon status in namespace %q check interval %q", monCluster.Namespace, checkInterval.Duration.String()) + h.interval = checkInterval.Duration } return h diff --git a/pkg/operator/ceph/cluster/mon/health_test.go b/pkg/operator/ceph/cluster/mon/health_test.go index 9e6ffd2c4..7684a4309 100644 --- a/pkg/operator/ceph/cluster/mon/health_test.go +++ b/pkg/operator/ceph/cluster/mon/health_test.go @@ -385,7 +385,7 @@ func TestAddOrRemoveExternalMonitor(t *testing.T) { func TestNewHealthChecker(t *testing.T) { c := &Cluster{spec: cephv1.ClusterSpec{HealthCheck: cephv1.CephClusterHealthCheckSpec{}}} time10s, _ := time.ParseDuration("10s") - c10s := &Cluster{spec: cephv1.ClusterSpec{HealthCheck: cephv1.CephClusterHealthCheckSpec{DaemonHealth: cephv1.DaemonHealthSpec{Monitor: cephv1.HealthCheckSpec{Interval: "10s"}}}}} + c10s := &Cluster{spec: cephv1.ClusterSpec{HealthCheck: cephv1.CephClusterHealthCheckSpec{DaemonHealth: cephv1.DaemonHealthSpec{Monitor: cephv1.HealthCheckSpec{Interval: &metav1.Duration{Duration: time10s}}}}}} type args struct { monCluster *Cluster diff --git a/pkg/operator/ceph/cluster/osd/health.go b/pkg/operator/ceph/cluster/osd/health.go index d5c448e73..527597f28 100644 --- a/pkg/operator/ceph/cluster/osd/health.go +++ b/pkg/operator/ceph/cluster/osd/health.go @@ -46,7 +46,7 @@ type OSDHealthMonitor struct { context *clusterd.Context clusterInfo *client.ClusterInfo removeOSDsIfOUTAndSafeToRemove bool - interval time.Duration + interval *time.Duration } // NewOSDHealthMonitor instantiates OSD monitoring @@ -55,16 +55,14 @@ func NewOSDHealthMonitor(context *clusterd.Context, clusterInfo *client.ClusterI context: context, clusterInfo: clusterInfo, removeOSDsIfOUTAndSafeToRemove: removeOSDsIfOUTAndSafeToRemove, - interval: defaultHealthCheckInterval, + interval: &defaultHealthCheckInterval, } // allow overriding the check interval checkInterval := healthCheck.DaemonHealth.ObjectStorageDaemon.Interval - if checkInterval != "" { - if duration, err := time.ParseDuration(checkInterval); err == nil { - logger.Infof("ceph osd status in namespace %q check interval %q", h.clusterInfo.Namespace, checkInterval) - h.interval = duration - } + if checkInterval != nil { + logger.Infof("ceph osd status in namespace %q check interval %q", h.clusterInfo.Namespace, checkInterval.Duration.String()) + h.interval = &checkInterval.Duration } return h @@ -75,7 +73,7 @@ func (m *OSDHealthMonitor) Start(stopCh chan struct{}) { for { select { - case <-time.After(m.interval): + case <-time.After(*m.interval): logger.Debug("checking osd processes status.") m.checkOSDHealth() diff --git a/pkg/operator/ceph/cluster/osd/health_test.go b/pkg/operator/ceph/cluster/osd/health_test.go index b3ca10028..de0c9f060 100644 --- a/pkg/operator/ceph/cluster/osd/health_test.go +++ b/pkg/operator/ceph/cluster/osd/health_test.go @@ -128,8 +128,8 @@ func TestNewOSDHealthMonitor(t *testing.T) { args args want *OSDHealthMonitor }{ - {"default-interval", args{c, false, cephv1.CephClusterHealthCheckSpec{}}, &OSDHealthMonitor{c, clusterInfo, false, defaultHealthCheckInterval}}, - {"10s-interval", args{c, false, cephv1.CephClusterHealthCheckSpec{DaemonHealth: cephv1.DaemonHealthSpec{ObjectStorageDaemon: cephv1.HealthCheckSpec{Interval: "10s"}}}}, &OSDHealthMonitor{c, clusterInfo, false, time10s}}, + {"default-interval", args{c, false, cephv1.CephClusterHealthCheckSpec{}}, &OSDHealthMonitor{c, clusterInfo, false, &defaultHealthCheckInterval}}, + {"10s-interval", args{c, false, cephv1.CephClusterHealthCheckSpec{DaemonHealth: cephv1.DaemonHealthSpec{ObjectStorageDaemon: cephv1.HealthCheckSpec{Interval: &metav1.Duration{Duration: time10s}}}}}, &OSDHealthMonitor{c, clusterInfo, false, &time10s}}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { diff --git a/pkg/operator/ceph/object/health.go b/pkg/operator/ceph/object/health.go index ab2eaf12b..af16928d1 100644 --- a/pkg/operator/ceph/object/health.go +++ b/pkg/operator/ceph/object/health.go @@ -29,19 +29,22 @@ import ( ) const ( - s3UserHealthCheckName = "rook-ceph-internal-s3-user-checker" - s3HealthCheckBucketName = "rook-ceph-bucket-checker" + s3UserHealthCheckName = "rook-ceph-internal-s3-user-checker" + s3HealthCheckBucketName = "rook-ceph-bucket-checker" + s3HealthCheckObjectBody = "Test Rook Object Data" + s3HealthCheckObjectKey = "rookHealthCheckTestObject" + contentType = "plain/text" +) + +var ( defaultHealthCheckInterval = 1 * time.Minute - s3HealthCheckObjectBody = "Test Rook Object Data" - s3HealthCheckObjectKey = "rookHealthCheckTestObject" - contentType = "plain/text" ) // bucketChecker aggregates the mon/cluster info needed to check the health of the monitors type bucketChecker struct { context *clusterd.Context objContext *Context - interval time.Duration + interval *time.Duration serviceIP string port string client client.Client @@ -54,7 +57,7 @@ func newBucketChecker(context *clusterd.Context, objContext *Context, serviceIP, c := &bucketChecker{ context: context, objContext: objContext, - interval: defaultHealthCheckInterval, + interval: &defaultHealthCheckInterval, serviceIP: serviceIP, port: port, namespacedName: namespacedName, @@ -64,11 +67,9 @@ func newBucketChecker(context *clusterd.Context, objContext *Context, serviceIP, // allow overriding the check interval checkInterval := healthCheckSpec.Bucket.Interval - if checkInterval != "" { - if duration, err := time.ParseDuration(checkInterval); err == nil { - logger.Infof("ceph rgw status check interval for object store %q is %q", namespacedName.Name, checkInterval) - c.interval = duration - } + if checkInterval != nil { + logger.Infof("ceph rgw status check interval for object store %q is %q", namespacedName.Name, checkInterval.Duration.String()) + c.interval = &checkInterval.Duration } return c @@ -92,7 +93,7 @@ func (c *bucketChecker) checkObjectStore(stopCh chan struct{}) { logger.Infof("stopping monitoring of rgw endpoints for object store %q", c.namespacedName.Name) return - case <-time.After(c.interval): + case <-time.After(*c.interval): logger.Debugf("checking rgw health of object store %q", c.namespacedName.Name) err := c.checkObjectStoreHealth() if err != nil { diff --git a/pkg/operator/ceph/pool/health.go b/pkg/operator/ceph/pool/health.go index d7afcc644..1dd90d27b 100644 --- a/pkg/operator/ceph/pool/health.go +++ b/pkg/operator/ceph/pool/health.go @@ -26,13 +26,13 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" ) -const ( +var ( defaultHealthCheckInterval = 1 * time.Minute ) type mirrorChecker struct { context *clusterd.Context - interval time.Duration + interval *time.Duration client client.Client clusterInfo *cephclient.ClusterInfo namespacedName types.NamespacedName @@ -44,7 +44,7 @@ type mirrorChecker struct { func newMirrorChecker(context *clusterd.Context, client client.Client, clusterInfo *cephclient.ClusterInfo, namespacedName types.NamespacedName, poolSpec *cephv1.PoolSpec, poolName string) *mirrorChecker { c := &mirrorChecker{ context: context, - interval: defaultHealthCheckInterval, + interval: &defaultHealthCheckInterval, clusterInfo: clusterInfo, namespacedName: namespacedName, client: client, @@ -54,11 +54,9 @@ func newMirrorChecker(context *clusterd.Context, client client.Client, clusterIn // allow overriding the check interval checkInterval := poolSpec.StatusCheck.Mirror.Interval - if checkInterval != "" { - if duration, err := time.ParseDuration(checkInterval); err == nil { - logger.Infof("pool mirroring status check interval for block pool %q is %q", namespacedName.Name, checkInterval) - c.interval = duration - } + if checkInterval != nil { + logger.Infof("pool mirroring status check interval for block pool %q is %q", namespacedName.Name, checkInterval.Duration.String()) + c.interval = &checkInterval.Duration } return c @@ -79,7 +77,7 @@ func (c *mirrorChecker) checkMirroring(stopCh chan struct{}) { logger.Infof("stopping monitoring pool mirroring status %q", c.namespacedName.Name) return - case <-time.After(c.interval): + case <-time.After(*c.interval): logger.Debugf("checking pool mirroring status %q", c.namespacedName.Name) err := c.checkMirroringHealth() if err != nil {