From 8686a8645cb513b15b70b636c6ae0b0dbceeb3b2 Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Fri, 23 Mar 2018 15:11:45 -0500 Subject: [PATCH 1/2] Default gossip seed should be empty instead of local bind address --- gossip/gossip.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/gossip/gossip.go b/gossip/gossip.go index 866d2e41e..b1c6902d8 100644 --- a/gossip/gossip.go +++ b/gossip/gossip.go @@ -63,6 +63,9 @@ func (g *GossipMemberSet) Start(h pilosa.BroadcastHandler) error { // Seeds returns the gossipSeeds determined by the config. func (g *GossipMemberSet) Seeds() []string { + if len(g.config.gossipSeeds) == 0 { + return []string{fmt.Sprintf("%s:%d", g.config.memberlistConfig.BindAddr, g.config.memberlistConfig.BindPort)} + } return g.config.gossipSeeds } @@ -202,11 +205,6 @@ func NewGossipMemberSetWithTransport(name string, cfg *pilosa.Config, transport g.statusHandler = server - // If no gossipSeeds is provided, use local host:port. - if len(cfg.Gossip.Seeds) == 0 { - g.config.gossipSeeds = []string{fmt.Sprintf("%s:%d", host, port)} - } - return g, nil } From 0ca7cfe498c51cfc415b73cb90bcaf11a7a4c1dc Mon Sep 17 00:00:00 2001 From: Travis Turner Date: Fri, 23 Mar 2018 16:34:19 -0500 Subject: [PATCH 2/2] Change Seeds() to GetBindAddr() to clarify GossipMemberSet testing. --- gossip/gossip.go | 11 +++++------ server/cluster_test.go | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/gossip/gossip.go b/gossip/gossip.go index b1c6902d8..62c794560 100644 --- a/gossip/gossip.go +++ b/gossip/gossip.go @@ -61,12 +61,11 @@ func (g *GossipMemberSet) Start(h pilosa.BroadcastHandler) error { return nil } -// Seeds returns the gossipSeeds determined by the config. -func (g *GossipMemberSet) Seeds() []string { - if len(g.config.gossipSeeds) == 0 { - return []string{fmt.Sprintf("%s:%d", g.config.memberlistConfig.BindAddr, g.config.memberlistConfig.BindPort)} - } - return g.config.gossipSeeds +// GetBindAddr returns the gossip bind address based on config and auto bind port. +// This method is currently only used in a test scenario where a second node needs +// the auto-bind address of the first node to use as its gossip seed. +func (g *GossipMemberSet) GetBindAddr() string { + return fmt.Sprintf("%s:%d", g.config.memberlistConfig.BindAddr, g.config.memberlistConfig.BindPort) } // Open implements the MemberSet interface to start network activity. diff --git a/server/cluster_test.go b/server/cluster_test.go index 81a410e83..fbb784691 100644 --- a/server/cluster_test.go +++ b/server/cluster_test.go @@ -78,7 +78,7 @@ func TestMain_SendReceiveMessage(t *testing.T) { // get the host portion of addr to use for binding m1.Config.Gossip.Port = "0" - m1.Config.Gossip.Seeds = gossipMemberSet0.Seeds() + m1.Config.Gossip.Seeds = []string{gossipMemberSet0.GetBindAddr()} m1.Server.Cluster.Coordinator = m0.Server.NodeID m1.Server.Cluster.EventReceiver = gossip.NewGossipEventReceiver(m1.Server.LogOutput)