consul: Server processes local Serf join

pull/179/head
Armon Dadgar 11 years ago
parent 1be705c410
commit a31a19040e

@ -18,11 +18,15 @@ func (s *Server) lanEventHandler() {
case e := <-s.eventChLAN: case e := <-s.eventChLAN:
switch e.EventType() { switch e.EventType() {
case serf.EventMemberJoin: case serf.EventMemberJoin:
fallthrough s.nodeJoin(e.(serf.MemberEvent), false)
s.localMemberEvent(e.(serf.MemberEvent))
case serf.EventMemberLeave: case serf.EventMemberLeave:
fallthrough fallthrough
case serf.EventMemberFailed: case serf.EventMemberFailed:
fallthrough s.nodeFailed(e.(serf.MemberEvent))
s.localMemberEvent(e.(serf.MemberEvent))
case serf.EventMemberReap: case serf.EventMemberReap:
s.localMemberEvent(e.(serf.MemberEvent)) s.localMemberEvent(e.(serf.MemberEvent))
case serf.EventUser: case serf.EventUser:
@ -46,11 +50,11 @@ func (s *Server) wanEventHandler() {
case e := <-s.eventChWAN: case e := <-s.eventChWAN:
switch e.EventType() { switch e.EventType() {
case serf.EventMemberJoin: case serf.EventMemberJoin:
s.remoteJoin(e.(serf.MemberEvent)) s.nodeJoin(e.(serf.MemberEvent), true)
case serf.EventMemberLeave: case serf.EventMemberLeave:
fallthrough fallthrough
case serf.EventMemberFailed: case serf.EventMemberFailed:
s.remoteFailed(e.(serf.MemberEvent)) s.nodeFailed(e.(serf.MemberEvent))
case serf.EventMemberUpdate: // Ignore case serf.EventMemberUpdate: // Ignore
case serf.EventMemberReap: // Ignore case serf.EventMemberReap: // Ignore
case serf.EventUser: case serf.EventUser:
@ -109,12 +113,14 @@ func (s *Server) localEvent(event serf.UserEvent) {
} }
} }
// remoteJoin is used to handle join events on the wan serf cluster // nodeJoin is used to handle join events on the both serf clusters
func (s *Server) remoteJoin(me serf.MemberEvent) { func (s *Server) nodeJoin(me serf.MemberEvent, wan bool) {
for _, m := range me.Members { for _, m := range me.Members {
ok, parts := isConsulServer(m) ok, parts := isConsulServer(m)
if !ok { if !ok {
if wan {
s.logger.Printf("[WARN] consul: non-server in WAN pool: %s %s", m.Name) s.logger.Printf("[WARN] consul: non-server in WAN pool: %s %s", m.Name)
}
continue continue
} }
s.logger.Printf("[INFO] consul: adding server %s", parts) s.logger.Printf("[INFO] consul: adding server %s", parts)
@ -139,8 +145,8 @@ func (s *Server) remoteJoin(me serf.MemberEvent) {
} }
} }
// remoteFailed is used to handle fail events on the wan serf cluster // nodeFailed is used to handle fail events on both the serf clustes
func (s *Server) remoteFailed(me serf.MemberEvent) { func (s *Server) nodeFailed(me serf.MemberEvent) {
for _, m := range me.Members { for _, m := range me.Members {
ok, parts := isConsulServer(m) ok, parts := isConsulServer(m)
if !ok { if !ok {

Loading…
Cancel
Save