mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
Use specific boolean for a leaf test instead of using leafNodeEnabled
A test TestJetStreamClusterLeafNodeSPOFMigrateLeaders was added at some point that needed the remotes to stop (re)connecting. It made use of existing leafNodeEnabled that was used for GW/Leaf interest propagation races to disable the reconnect, but that may not be the best approach since it could affect users embedding servers and adding leafnodes "dynamically". So this PR introduced a specific boolean specific for that test. Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
@@ -951,7 +951,7 @@ func (s *Server) closeAndDisableLeafnodes() {
|
||||
leafs = append(leafs, ln)
|
||||
}
|
||||
// Disable leafnodes for now.
|
||||
s.leafNodeEnabled = false
|
||||
s.leafDisableConnect = true
|
||||
s.mu.Unlock()
|
||||
|
||||
for _, ln := range leafs {
|
||||
|
||||
@@ -495,12 +495,13 @@ func (s *Server) connectToRemoteLeafNode(remote *leafNodeCfg, firstConnect bool)
|
||||
if url != rURL.Host {
|
||||
ipStr = fmt.Sprintf(" (%s)", url)
|
||||
}
|
||||
if s.isLeafNodeEnabled() {
|
||||
s.Debugf("Trying to connect as leafnode to remote server on %q%s", rURL.Host, ipStr)
|
||||
conn, err = natsDialTimeout("tcp", url, dialTimeout)
|
||||
} else {
|
||||
// Some test may want to disable remotes from connecting
|
||||
if s.isLeafConnectDisabled() {
|
||||
s.Debugf("Will not attempt to connect to remote server on %q%s, leafnodes currently disabled", rURL.Host, ipStr)
|
||||
err = ErrLeafNodeDisabled
|
||||
} else {
|
||||
s.Debugf("Trying to connect as leafnode to remote server on %q%s", rURL.Host, ipStr)
|
||||
conn, err = natsDialTimeout("tcp", url, dialTimeout)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
@@ -569,10 +570,10 @@ func (s *Server) checkJetStreamMigrate(remote *leafNodeCfg) {
|
||||
}
|
||||
|
||||
// Helper for checking.
|
||||
func (s *Server) isLeafNodeEnabled() bool {
|
||||
func (s *Server) isLeafConnectDisabled() bool {
|
||||
s.mu.RLock()
|
||||
defer s.mu.RUnlock()
|
||||
return s.leafNodeEnabled
|
||||
return s.leafDisableConnect
|
||||
}
|
||||
|
||||
// Save off the tlsName for when we use TLS and mix hostnames and IPs. IPs usually
|
||||
|
||||
@@ -164,6 +164,7 @@ type Server struct {
|
||||
leafRemoteCfgs []*leafNodeCfg
|
||||
leafRemoteAccounts sync.Map
|
||||
leafNodeEnabled bool
|
||||
leafDisableConnect bool // Used in test only
|
||||
|
||||
quitCh chan struct{}
|
||||
startupComplete chan struct{}
|
||||
|
||||
Reference in New Issue
Block a user