Skip to content

Commit

Permalink
Merge pull request YotpoLtd#19 from seatgeek/fix-master-nil-adress
Browse files Browse the repository at this point in the history
Use consul node adress if service addr is empty
  • Loading branch information
burdandrei authored May 31, 2020
2 parents 186cd43 + 9db7c95 commit 6602a34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion resec/consul/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,14 @@ func (m *Manager) watchConsulMasterService() {
continue
}

m.state.MasterAddr = master.Service.Address
// handle If master is registred in consul with port only
// Use node IP insted of service IP
if master.Service.Address != "" {
m.state.MasterAddr = master.Service.Address
} else {
m.state.MasterAddr = master.Node.Address
}

m.state.MasterPort = master.Service.Port
m.emit()

Expand Down
1 change: 1 addition & 0 deletions resec/consul/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ func NewConnection(c *cli.Context, redisConfig redis.Config) (*Manager, error) {
if announceAddr == "" {
redisHost := strings.Split(redisConfig.Address, ":")[0]
redisPort := strings.Split(redisConfig.Address, ":")[1]
// If REDIS_ADDR is declared as localhost register only port, and rely on consul to bring the agents IP
if redisHost == "127.0.0.1" || redisHost == "localhost" || redisHost == "::1" {
consulConfig.announceAddr = ":" + redisPort
} else {
Expand Down

0 comments on commit 6602a34

Please sign in to comment.