diff --git a/metrics/metrics.go b/metrics/metrics.go index 1087b3dec..626f12aad 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -56,6 +56,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 89a0c2f19..1671da74d 100644 --- a/operator/redisfailover/checker.go +++ b/operator/redisfailover/checker.go @@ -249,7 +249,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 e54f49005..b65c782b2 100644 --- a/operator/redisfailover/service/check.go +++ b/operator/redisfailover/service/check.go @@ -230,10 +230,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 8c42690bf..3364de495 100644 --- a/service/redis/client.go +++ b/service/redis/client.go @@ -239,6 +239,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 } } @@ -258,7 +259,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 }