diff --git a/metrics/metrics.go b/metrics/metrics.go index 3b07785a5..c4d8b09fa 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -55,6 +55,7 @@ const ( KIND_REDIS = "REDIS" KIND_SENTINEL = "SENTINEL" APPLY_REDIS_CONFIG = "APPLY_REDIS_CONFIG" + APPLY_EXTERNAL_MASTER = "APPLY_EXT_MASTER_ALL" APPLY_SENTINEL_CONFIG = "APPLY_SENTINEL_CONFIG" MONITOR_REDIS_WITH_PORT = "SET_SENTINEL_TO_MONITOR_REDIS_WITH_GIVEN_PORT" RESET_SENTINEL = "RESET_ALL_SENTINEL_CONFIG" diff --git a/operator/redisfailover/checker.go b/operator/redisfailover/checker.go index 0324b341b..ff9a41554 100644 --- a/operator/redisfailover/checker.go +++ b/operator/redisfailover/checker.go @@ -216,7 +216,9 @@ func (r *RedisFailoverHandler) checkAndHealBootstrapMode(rf *redisfailoverv1.Red } bootstrapSettings := rf.Spec.BootstrapNode - if err := r.rfHealer.SetExternalMasterOnAll(bootstrapSettings.Host, bootstrapSettings.Port, rf); err != nil { + err = r.rfHealer.SetExternalMasterOnAll(bootstrapSettings.Host, bootstrapSettings.Port, rf) + setRedisCheckerMetrics(r.mClient, "redis", rf.Namespace, rf.Name, metrics.APPLY_EXTERNAL_MASTER, metrics.NOT_APPLICABLE, err) + if err != nil { return err } diff --git a/operator/redisfailover/service/check.go b/operator/redisfailover/service/check.go index 1a2a94914..767a19c8f 100644 --- a/operator/redisfailover/service/check.go +++ b/operator/redisfailover/service/check.go @@ -153,10 +153,19 @@ func (r *RedisFailoverChecker) CheckSentinelSlavesNumberInMemory(sentinel string nSlaves, err := r.redisClient.GetNumberSentinelSlavesInMemory(sentinel) if err != nil { return err - } else if nSlaves != rf.Spec.Redis.Replicas-1 { - return errors.New("redis slaves in sentinel memory mismatch") + } else { + if rf.Bootstrapping() { + if nSlaves != rf.Spec.Redis.Replicas { + return errors.New("redis slaves in sentinel memory mismatch") + } + } else { + if nSlaves != rf.Spec.Redis.Replicas-1 { + return errors.New("redis slaves in sentinel memory mismatch") + } + } } return nil + } // CheckSentinelMonitor controls if the sentinels are monitoring the expected master diff --git a/service/redis/client.go b/service/redis/client.go index bb89c1f96..a9a0feecc 100644 --- a/service/redis/client.go +++ b/service/redis/client.go @@ -238,6 +238,7 @@ func (c *client) MonitorRedisWithPort(ip, monitor, port, quorum, password string } _, err = cmd.Result() if err != nil { + c.metricsRecorder.RecordRedisOperation(metrics.KIND_REDIS, ip, metrics.MONITOR_REDIS_WITH_PORT, metrics.FAIL, getRedisError(err)) return err } } @@ -257,7 +258,7 @@ func (c *client) MakeMaster(ip string, port string, password string) error { c.metricsRecorder.RecordRedisOperation(metrics.KIND_REDIS, ip, metrics.MAKE_MASTER, metrics.FAIL, getRedisError(res.Err())) return res.Err() } - c.metricsRecorder.RecordRedisOperation(metrics.KIND_REDIS, ip, metrics.MAKE_MASTER, metrics.FAIL, metrics.NOT_APPLICABLE) + c.metricsRecorder.RecordRedisOperation(metrics.KIND_REDIS, ip, metrics.MAKE_MASTER, metrics.SUCCESS, metrics.NOT_APPLICABLE) return nil }