Skip to content

Commit e3f9edd

Browse files
committed
libn/networkdb: advertise the configured bind port
The NetworkDB unit tests instantiate clusters which communicate over loopback where every "node" listens on a distinct localhost port. The tests make use of a NetworkDB configuration knob to set the port. When the NetworkDB configuration's BindPort field is set to a nonzero value, its memberlist instance is configured to bind to the specified port number. However, the advertise port is left at the memberlist.DefaultLANConfig() default value of 7946. Because of this, nodes would be unable to contact any of the other nodes in the cluster learned by gossip as the gossiped addresseses specify the wrong ports! The flaky tests passed as often as they did thanks to the robustness of the memberlist module: NetworkDB gossip and and memberlist node liveness-probe pings to unreachable nodes can all be relayed through the reachable nodes, the nodes on the bootstrap join list. Make the NetworkDB unit tests less flaky by setting each node's advertise port to the bind port. The daemon is unaffected by this oversight as it unconditionally uses the default listen port of 7946, which aligns with the advertise port. Signed-off-by: Cory Snider <[email protected]>
1 parent d71afd7 commit e3f9edd

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

libnetwork/networkdb/cluster.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ func (nDB *NetworkDB) clusterInit() error {
112112

113113
if nDB.config.BindPort != 0 {
114114
config.BindPort = nDB.config.BindPort
115+
config.AdvertisePort = nDB.config.BindPort
115116
}
116117

117118
config.ProtocolVersion = memberlist.ProtocolVersion2Compatible

0 commit comments

Comments
 (0)