Skip to content
This repository has been archived by the owner on Mar 10, 2019. It is now read-only.

As Sentinel doesn't support AUTH command (as of Redis 4.0.7), passwor… #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 7 additions & 7 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
)

var (
ListenAddress = "127.0.0.1:6379" // Redundis listen address
SentinelAddress = "127.0.0.1:26379" // Address of sentinel node
SentinelPassword = "" // Sentinel password
MonitorName = "test" // Name of sentinel monitor
ListenAddress = "127.0.0.1:6379" // Redundis listen address
SentinelAddress = "127.0.0.1:26379" // Address of sentinel node
MasterPassword = "" // Redis Master password
MonitorName = "test" // Name of sentinel monitor

masterWait = 30
notReady = 30
Expand All @@ -36,7 +36,7 @@ func init() {
func AddFlags(cmd *cobra.Command) {
cmd.Flags().StringVarP(&ListenAddress, "listen-address", "l", ListenAddress, "Redundis listen address")
cmd.Flags().StringVarP(&SentinelAddress, "sentinel-address", "s", SentinelAddress, "Address of sentinel node")
cmd.Flags().StringVarP(&SentinelPassword, "sentinel-password", "p", SentinelPassword, "Sentinel password")
cmd.Flags().StringVarP(&MasterPassword, "master-password", "p", MasterPassword, "Master password")
cmd.Flags().StringVarP(&MonitorName, "monitor-name", "m", MonitorName, "Name of sentinel monitor")

// timeouts
Expand All @@ -60,7 +60,7 @@ func ReadConfigFile(configFile string) error {
// Set defaults to whatever might be there already
viper.SetDefault("listen-address", ListenAddress)
viper.SetDefault("sentinel-address", SentinelAddress)
viper.SetDefault("sentinel-password", SentinelPassword)
viper.SetDefault("master-password", MasterPassword)
viper.SetDefault("monitor-name", MonitorName)
viper.SetDefault("master-wait", masterWait)
viper.SetDefault("ready-wait", notReady)
Expand All @@ -79,7 +79,7 @@ func ReadConfigFile(configFile string) error {
// Set values. Config file will override commandline
ListenAddress = viper.GetString("listen-address")
SentinelAddress = viper.GetString("sentinel-address")
SentinelPassword = viper.GetString("sentinel-password")
MasterPassword = viper.GetString("master-password")
MonitorName = viper.GetString("monitor-name")
TimeoutMasterWait = time.Duration(viper.GetInt("master-wait")) * time.Second
TimeoutNotReady = time.Duration(viper.GetInt("ready-wait")) * time.Second
Expand Down
4 changes: 2 additions & 2 deletions core/redundis.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func updateMaster() error {
config.Log.Debug("Contacting sentinel for address of master...")

// connect to sentinel in order to query for the master address
r, err := redis.DialURL("redis://"+config.SentinelAddress, redis.DialConnectTimeout(config.TimeoutNotReady), redis.DialReadTimeout(config.TimeoutSentinelPoll), redis.DialPassword(config.SentinelPassword))
r, err := redis.DialURL("redis://"+config.SentinelAddress, redis.DialConnectTimeout(config.TimeoutNotReady), redis.DialReadTimeout(config.TimeoutSentinelPoll))
if err != nil {
return fmt.Errorf("Failed to reach sentinel - %v", err)
}
Expand All @@ -113,7 +113,7 @@ func updateMaster() error {
config.Log.Debug("Master address: '%v'", masterAddr)

// wait for redis to transition to master
if err = verifyMaster(masterAddr, config.SentinelPassword); err != nil {
if err = verifyMaster(masterAddr, config.MasterPassword); err != nil {
return fmt.Errorf("Could not verify master - %v", err)
}

Expand Down