Moves reconcile loop into segment stub.
This commit is contained in:
parent
ae7137119f
commit
7c616e3768
|
@ -328,25 +328,6 @@ func (s *Server) getOrCreateAutopilotConfig() (*structs.AutopilotConfig, bool) {
|
||||||
return config, true
|
return config, true
|
||||||
}
|
}
|
||||||
|
|
||||||
// reconcile is used to reconcile the differences between Serf
|
|
||||||
// membership and what is reflected in our strongly consistent store.
|
|
||||||
// Mainly we need to ensure all live nodes are registered, all failed
|
|
||||||
// nodes are marked as such, and all left nodes are de-registered.
|
|
||||||
func (s *Server) reconcile() (err error) {
|
|
||||||
defer metrics.MeasureSince([]string{"consul", "leader", "reconcile"}, time.Now())
|
|
||||||
members := s.serfLAN.Members()
|
|
||||||
knownMembers := make(map[string]struct{})
|
|
||||||
for _, member := range members {
|
|
||||||
if err := s.reconcileMember(member); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
knownMembers[member.Name] = struct{}{}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reconcile any members that have been reaped while we were not the leader
|
|
||||||
return s.reconcileReaped(knownMembers)
|
|
||||||
}
|
|
||||||
|
|
||||||
// reconcileReaped is used to reconcile nodes that have failed and been reaped
|
// reconcileReaped is used to reconcile nodes that have failed and been reaped
|
||||||
// from Serf but remain in the catalog. This is done by looking for SerfCheckID
|
// from Serf but remain in the catalog. This is done by looking for SerfCheckID
|
||||||
// in a critical state that does not correspond to a known Serf member. We generate
|
// in a critical state that does not correspond to a known Serf member. We generate
|
||||||
|
|
|
@ -4,7 +4,9 @@ package consul
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/armon/go-metrics"
|
||||||
"github.com/hashicorp/consul/agent/structs"
|
"github.com/hashicorp/consul/agent/structs"
|
||||||
"github.com/hashicorp/serf/serf"
|
"github.com/hashicorp/serf/serf"
|
||||||
)
|
)
|
||||||
|
@ -51,3 +53,23 @@ func (s *Server) setupSegments(config *Config, port int, rpcListeners map[string
|
||||||
// floodSegments is a NOP in the OSS version of Consul.
|
// floodSegments is a NOP in the OSS version of Consul.
|
||||||
func (s *Server) floodSegments(config *Config) {
|
func (s *Server) floodSegments(config *Config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reconcile is used to reconcile the differences between Serf membership and
|
||||||
|
// what is reflected in our strongly consistent store. Mainly we need to ensure
|
||||||
|
// all live nodes are registered, all failed nodes are marked as such, and all
|
||||||
|
// left nodes are de-registered.
|
||||||
|
func (s *Server) reconcile() (err error) {
|
||||||
|
defer metrics.MeasureSince([]string{"consul", "leader", "reconcile"}, time.Now())
|
||||||
|
members := s.serfLAN.Members()
|
||||||
|
knownMembers := make(map[string]struct{})
|
||||||
|
for _, member := range members {
|
||||||
|
if err := s.reconcileMember(member); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
knownMembers[member.Name] = struct{}{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reconcile any members that have been reaped while we were not the
|
||||||
|
// leader.
|
||||||
|
return s.reconcileReaped(knownMembers)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue