close raft long-lived connections
This commit is contained in:
parent
acd3d1b162
commit
dfb6a3d9a8
|
@ -51,7 +51,7 @@ func (l *RaftLayer) Handoff(c net.Conn, ctx context.Context) error {
|
||||||
case <-l.closeCh:
|
case <-l.closeCh:
|
||||||
return fmt.Errorf("Raft RPC layer closed")
|
return fmt.Errorf("Raft RPC layer closed")
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return fmt.Errorf("[INFO] nomad.rpc: Closing server RPC connection")
|
return fmt.Errorf("[INFO] nomad.rpc: Closing raft RPC connection")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -405,14 +405,16 @@ func (s *Server) ReloadTLSConnections(newTLSConfig *config.TLSConfig) error {
|
||||||
}
|
}
|
||||||
s.rpcListener = list
|
s.rpcListener = list
|
||||||
|
|
||||||
|
wrapper := tlsutil.RegionSpecificWrapper(s.config.Region, tlsWrap)
|
||||||
|
s.raftLayer.ReloadTLS(wrapper)
|
||||||
|
s.raftTransport.Reload()
|
||||||
|
time.Sleep(500 * time.Millisecond)
|
||||||
|
|
||||||
// reinitialize the cancel context
|
// reinitialize the cancel context
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
s.rpcCancel = cancel
|
s.rpcCancel = cancel
|
||||||
go s.listen(ctx)
|
go s.listen(ctx)
|
||||||
|
|
||||||
wrapper := tlsutil.RegionSpecificWrapper(s.config.Region, tlsWrap)
|
|
||||||
s.raftLayer.ReloadTLS(wrapper)
|
|
||||||
|
|
||||||
s.logger.Printf("[INFO] nomad: finished reloading server connections")
|
s.logger.Printf("[INFO] nomad: finished reloading server connections")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,6 +177,19 @@ func (n *NetworkTransport) Close() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (n *NetworkTransport) Reload() {
|
||||||
|
n.shutdownLock.Lock()
|
||||||
|
defer n.shutdownLock.Unlock()
|
||||||
|
|
||||||
|
if !n.shutdown {
|
||||||
|
close(n.shutdownCh)
|
||||||
|
n.shutdown = true
|
||||||
|
}
|
||||||
|
|
||||||
|
time.Sleep(3 * time.Second)
|
||||||
|
n.shutdownCh = make(chan struct{})
|
||||||
|
}
|
||||||
|
|
||||||
// Consumer implements the Transport interface.
|
// Consumer implements the Transport interface.
|
||||||
func (n *NetworkTransport) Consumer() <-chan RPC {
|
func (n *NetworkTransport) Consumer() <-chan RPC {
|
||||||
return n.consumeCh
|
return n.consumeCh
|
||||||
|
|
Loading…
Reference in New Issue