mirror of https://github.com/status-im/consul.git
consul: Cleanup the FSM, running out of file handles
This commit is contained in:
parent
630aa33cf4
commit
697d9e7ed8
|
@ -46,6 +46,11 @@ func NewFSM(logOutput io.Writer) (*consulFSM, error) {
|
|||
return fsm, nil
|
||||
}
|
||||
|
||||
// Close is used to cleanup resources associated with the FSM
|
||||
func (c *consulFSM) Close() error {
|
||||
return c.state.Close()
|
||||
}
|
||||
|
||||
// State is used to return a handle to the current state
|
||||
func (c *consulFSM) State() *StateStore {
|
||||
return c.state
|
||||
|
|
|
@ -40,6 +40,7 @@ func TestFSM_RegisterNode(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
defer fsm.Close()
|
||||
|
||||
req := structs.RegisterRequest{
|
||||
Datacenter: "dc1",
|
||||
|
@ -75,6 +76,7 @@ func TestFSM_RegisterNode_Service(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
defer fsm.Close()
|
||||
|
||||
req := structs.RegisterRequest{
|
||||
Datacenter: "dc1",
|
||||
|
@ -127,6 +129,7 @@ func TestFSM_DeregisterService(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
defer fsm.Close()
|
||||
|
||||
req := structs.RegisterRequest{
|
||||
Datacenter: "dc1",
|
||||
|
@ -181,6 +184,7 @@ func TestFSM_DeregisterCheck(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
defer fsm.Close()
|
||||
|
||||
req := structs.RegisterRequest{
|
||||
Datacenter: "dc1",
|
||||
|
@ -235,6 +239,7 @@ func TestFSM_DeregisterNode(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
defer fsm.Close()
|
||||
|
||||
req := structs.RegisterRequest{
|
||||
Datacenter: "dc1",
|
||||
|
@ -301,6 +306,7 @@ func TestFSM_SnapshotRestore(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
defer fsm.Close()
|
||||
|
||||
// Add some state
|
||||
fsm.state.EnsureNode(1, structs.Node{"foo", "127.0.0.1"})
|
||||
|
@ -336,6 +342,7 @@ func TestFSM_SnapshotRestore(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatalf("err: %v", err)
|
||||
}
|
||||
defer fsm2.Close()
|
||||
|
||||
// Do a restore
|
||||
if err := fsm2.Restore(sink); err != nil {
|
||||
|
|
|
@ -336,6 +336,9 @@ func (s *Server) Shutdown() error {
|
|||
// Close the connection pool
|
||||
s.connPool.Shutdown()
|
||||
|
||||
// Close the fsm
|
||||
s.fsm.Close()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue