Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor fixes on metrics #539

Merged
merged 1 commit into from
Dec 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion operator/redisfailover/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

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

Expand Down