Skip to content

Commit

Permalink
Merge pull request #539 from dinesh-murugiah/metrics_fixes
Browse files Browse the repository at this point in the history
minor fixes on metrics
  • Loading branch information
ese authored Dec 9, 2022
2 parents ea4f232 + d3c1c8e commit 3331ba3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion operator/redisfailover/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
13 changes: 11 additions & 2 deletions operator/redisfailover/service/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion service/redis/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand All @@ -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
}

Expand Down

0 comments on commit 3331ba3

Please sign in to comment.