Log cleanup
This commit is contained in:
parent
c2ef218c30
commit
c5e2004be9
|
@ -103,7 +103,7 @@ func (c *Client) setupSerf(conf *serf.Config, ch chan serf.Event, path string) (
|
|||
|
||||
// Shutdown is used to shutdown the client
|
||||
func (c *Client) Shutdown() error {
|
||||
c.logger.Printf("[INFO] Shutting down Consul client")
|
||||
c.logger.Printf("[INFO] consul: shutting down client")
|
||||
c.shutdownLock.Lock()
|
||||
defer c.shutdownLock.Unlock()
|
||||
|
||||
|
@ -125,12 +125,12 @@ func (c *Client) Shutdown() error {
|
|||
|
||||
// Leave is used to prepare for a graceful shutdown
|
||||
func (c *Client) Leave() error {
|
||||
c.logger.Printf("[INFO] Consul client starting leave")
|
||||
c.logger.Printf("[INFO] consul: client starting leave")
|
||||
|
||||
// Leave the LAN pool
|
||||
if c.serf != nil {
|
||||
if err := c.serf.Leave(); err != nil {
|
||||
c.logger.Printf("[ERR] Failed to leave LAN Serf cluster: %v", err)
|
||||
c.logger.Printf("[ERR] consul: Failed to leave LAN Serf cluster: %v", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
@ -167,7 +167,7 @@ func (c *Client) lanEventHandler() {
|
|||
c.nodeFail(e.(serf.MemberEvent))
|
||||
case serf.EventUser:
|
||||
default:
|
||||
c.logger.Printf("[WARN] Unhandled LAN Serf Event: %#v", e)
|
||||
c.logger.Printf("[WARN] consul: unhandled LAN Serf Event: %#v", e)
|
||||
}
|
||||
case <-c.shutdownCh:
|
||||
return
|
||||
|
@ -183,13 +183,13 @@ func (c *Client) nodeJoin(me serf.MemberEvent) {
|
|||
continue
|
||||
}
|
||||
if dc != c.config.Datacenter {
|
||||
c.logger.Printf("[WARN] Consul server %s for datacenter %s has joined wrong cluster",
|
||||
c.logger.Printf("[WARN] consul: server %s for datacenter %s has joined wrong cluster",
|
||||
m.Name, dc)
|
||||
continue
|
||||
}
|
||||
|
||||
var addr net.Addr = &net.TCPAddr{IP: m.Addr, Port: port}
|
||||
c.logger.Printf("[INFO] Adding Consul server (Datacenter: %s) (Addr: %s)", dc, addr)
|
||||
c.logger.Printf("[INFO] consul: adding server for datacenter: %s, addr: %s", dc, addr)
|
||||
|
||||
// Check if this server is known
|
||||
found := false
|
||||
|
@ -217,7 +217,7 @@ func (c *Client) nodeFail(me serf.MemberEvent) {
|
|||
continue
|
||||
}
|
||||
var addr net.Addr = &net.TCPAddr{IP: m.Addr, Port: port}
|
||||
c.logger.Printf("[INFO] Removing Consul server (Datacenter: %s) (Addr: %s)", dc, addr)
|
||||
c.logger.Printf("[INFO] consul: removing server for datacenter: %s, addr: %s", dc, addr)
|
||||
|
||||
// Remove the server if known
|
||||
c.consulLock.Lock()
|
||||
|
|
|
@ -100,7 +100,7 @@ func (c *consulFSM) applyDeregister(buf []byte) interface{} {
|
|||
|
||||
func (c *consulFSM) Snapshot() (raft.FSMSnapshot, error) {
|
||||
defer func(start time.Time) {
|
||||
log.Printf("[INFO] FSM Snapshot created in %v", time.Now().Sub(start))
|
||||
log.Printf("[INFO] consul: FSM snapshot created in %v", time.Now().Sub(start))
|
||||
}(time.Now())
|
||||
|
||||
// Create a new snapshot
|
||||
|
|
|
@ -83,7 +83,7 @@ func (s *Server) reconcile() (err error) {
|
|||
func (s *Server) reconcileMember(member serf.Member) error {
|
||||
// Check if this is a member we should handle
|
||||
if !s.shouldHandleMember(member) {
|
||||
s.logger.Printf("[WARN] Skipping reconcile of node %v", member)
|
||||
s.logger.Printf("[WARN] consul: skipping reconcile of node %v", member)
|
||||
return nil
|
||||
}
|
||||
var err error
|
||||
|
@ -96,7 +96,7 @@ func (s *Server) reconcileMember(member serf.Member) error {
|
|||
err = s.handleLeftMember(member)
|
||||
}
|
||||
if err != nil {
|
||||
s.logger.Printf("[ERR] Failed to reconcile member: %v: %v",
|
||||
s.logger.Printf("[ERR] consul: failed to reconcile member: %v: %v",
|
||||
member, err)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ type Raft struct {
|
|||
func (r *Raft) RemovePeer(args string, reply *struct{}) error {
|
||||
peer, err := net.ResolveTCPAddr("tcp", args)
|
||||
if err != nil {
|
||||
r.server.logger.Printf("[ERR] Failed to parse peer: %v", err)
|
||||
r.server.logger.Printf("[ERR] consul.raft: failed to parse peer: %v", err)
|
||||
return err
|
||||
}
|
||||
future := r.server.raft.RemovePeer(peer)
|
||||
|
|
|
@ -25,7 +25,7 @@ func (s *Server) listen() {
|
|||
if s.shutdown {
|
||||
return
|
||||
}
|
||||
s.logger.Printf("[ERR] Failed to accept RPC conn: %v", err)
|
||||
s.logger.Printf("[ERR] consul.rpc: failed to accept RPC conn: %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ func (s *Server) handleConn(conn net.Conn) {
|
|||
// Read a single byte
|
||||
buf := make([]byte, 1)
|
||||
if _, err := conn.Read(buf); err != nil {
|
||||
s.logger.Printf("[ERR] Failed to read byte: %v", err)
|
||||
s.logger.Printf("[ERR] consul.rpc: failed to read byte: %v", err)
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ func (s *Server) handleConn(conn net.Conn) {
|
|||
s.raftLayer.Handoff(conn)
|
||||
|
||||
default:
|
||||
s.logger.Printf("[ERR] Unrecognized RPC byte: %v", buf[0])
|
||||
s.logger.Printf("[ERR] consul.rpc: unrecognized RPC byte: %v", buf[0])
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ func (s *Server) handleConsulConn(conn net.Conn) {
|
|||
for !s.shutdown {
|
||||
if err := s.rpcServer.ServeRequest(rpcCodec); err != nil {
|
||||
if err != io.EOF {
|
||||
s.logger.Printf("[ERR] RPC error: %v (%v)", err, conn)
|
||||
s.logger.Printf("[ERR] consul.rpc: RPC error: %v (%v)", err, conn)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ func (s *Server) forwardDC(method, dc string, args interface{}, reply interface{
|
|||
servers := s.remoteConsuls[dc]
|
||||
if len(servers) == 0 {
|
||||
s.remoteLock.RUnlock()
|
||||
s.logger.Printf("[WARN] consul: RPC request for DC '%s', no path found", dc)
|
||||
s.logger.Printf("[WARN] consul.rpc: RPC request for DC '%s', no path found", dc)
|
||||
return structs.ErrNoDCPath
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ func (s *Server) lanEventHandler() {
|
|||
s.localMemberEvent(e.(serf.MemberEvent))
|
||||
case serf.EventUser:
|
||||
default:
|
||||
s.logger.Printf("[WARN] Unhandled LAN Serf Event: %#v", e)
|
||||
s.logger.Printf("[WARN] consul: unhandled LAN Serf Event: %#v", e)
|
||||
}
|
||||
|
||||
case <-s.shutdownCh:
|
||||
|
@ -45,7 +45,7 @@ func (s *Server) wanEventHandler() {
|
|||
s.remoteFailed(e.(serf.MemberEvent))
|
||||
case serf.EventUser:
|
||||
default:
|
||||
s.logger.Printf("[WARN] Unhandled LAN Serf Event: %#v", e)
|
||||
s.logger.Printf("[WARN] consul: unhandled WAN Serf Event: %#v", e)
|
||||
}
|
||||
|
||||
case <-s.shutdownCh:
|
||||
|
@ -77,7 +77,7 @@ func (s *Server) localJoin(me serf.MemberEvent) {
|
|||
continue
|
||||
}
|
||||
if dc != s.config.Datacenter {
|
||||
s.logger.Printf("[WARN] Consul server %s for datacenter %s has joined wrong cluster",
|
||||
s.logger.Printf("[WARN] consul: server %s for datacenter %s has joined wrong cluster",
|
||||
m.Name, dc)
|
||||
continue
|
||||
}
|
||||
|
@ -90,11 +90,11 @@ func (s *Server) remoteJoin(me serf.MemberEvent) {
|
|||
for _, m := range me.Members {
|
||||
ok, dc, port := isConsulServer(m)
|
||||
if !ok {
|
||||
s.logger.Printf("[WARN] Non-Consul server in WAN pool: %s %s", m.Name)
|
||||
s.logger.Printf("[WARN] consul: non-server in WAN pool: %s %s", m.Name)
|
||||
continue
|
||||
}
|
||||
var addr net.Addr = &net.TCPAddr{IP: m.Addr, Port: port}
|
||||
s.logger.Printf("[INFO] Adding Consul server (Datacenter: %s) (Addr: %s)", dc, addr)
|
||||
s.logger.Printf("[INFO] consul: adding server for datacenter: %s, addr: %s", dc, addr)
|
||||
|
||||
// Check if this server is known
|
||||
found := false
|
||||
|
@ -123,7 +123,7 @@ func (s *Server) remoteFailed(me serf.MemberEvent) {
|
|||
continue
|
||||
}
|
||||
var addr net.Addr = &net.TCPAddr{IP: m.Addr, Port: port}
|
||||
s.logger.Printf("[INFO] Removing Consul server (Datacenter: %s) (Addr: %s)", dc, addr)
|
||||
s.logger.Printf("[INFO] consul: removing server for datacenter: %s, addr: %s", dc, addr)
|
||||
|
||||
// Remove the server if known
|
||||
s.remoteLock.Lock()
|
||||
|
@ -160,7 +160,7 @@ CHECK:
|
|||
// Get the Raft peers
|
||||
peers, err := s.raftPeers.Peers()
|
||||
if err != nil {
|
||||
s.logger.Printf("[ERR] Failed to get raft peers: %v", err)
|
||||
s.logger.Printf("[ERR] consul: failed to get raft peers: %v", err)
|
||||
goto WAIT
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ CHECK:
|
|||
// Attempt to add as a peer
|
||||
future = s.raft.AddPeer(addr)
|
||||
if err := future.Error(); err != nil {
|
||||
s.logger.Printf("[ERR] Failed to add raft peer: %v", err)
|
||||
s.logger.Printf("[ERR] consul: failed to add raft peer: %v", err)
|
||||
} else {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -280,7 +280,7 @@ func (s *Server) setupRPC() error {
|
|||
|
||||
// Shutdown is used to shutdown the server
|
||||
func (s *Server) Shutdown() error {
|
||||
s.logger.Printf("[INFO] Shutting down Consul server")
|
||||
s.logger.Printf("[INFO] consul: shutting down server")
|
||||
s.shutdownLock.Lock()
|
||||
defer s.shutdownLock.Unlock()
|
||||
|
||||
|
@ -328,19 +328,19 @@ func (s *Server) Shutdown() error {
|
|||
|
||||
// Leave is used to prepare for a graceful shutdown of the server
|
||||
func (s *Server) Leave() error {
|
||||
s.logger.Printf("[INFO] Consul server starting leave")
|
||||
s.logger.Printf("[INFO] consul: server starting leave")
|
||||
|
||||
// Leave the WAN pool
|
||||
if s.serfWAN != nil {
|
||||
if err := s.serfWAN.Leave(); err != nil {
|
||||
s.logger.Printf("[ERR] Failed to leave WAN Serf cluster: %v", err)
|
||||
s.logger.Printf("[ERR] consul: failed to leave WAN Serf cluster: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Leave the LAN pool
|
||||
if s.serfLAN != nil {
|
||||
if err := s.serfLAN.Leave(); err != nil {
|
||||
s.logger.Printf("[ERR] Failed to leave LAN Serf cluster: %v", err)
|
||||
s.logger.Printf("[ERR] consul: failed to leave LAN Serf cluster: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -349,14 +349,14 @@ func (s *Server) Leave() error {
|
|||
// Check if we have other raft nodes
|
||||
peers, _ := s.raftPeers.Peers()
|
||||
if len(peers) <= 1 {
|
||||
s.logger.Printf("[WARN] Not leaving Raft cluster, no peers")
|
||||
s.logger.Printf("[WARN] consul: not leaving Raft cluster, no peers")
|
||||
goto AFTER_LEAVE
|
||||
}
|
||||
|
||||
// Get the leader
|
||||
leader := s.raft.Leader()
|
||||
if leader == nil {
|
||||
s.logger.Printf("[ERR] Failed to leave Raft cluster: no leader")
|
||||
s.logger.Printf("[ERR] consul: failed to leave Raft cluster: no leader")
|
||||
goto AFTER_LEAVE
|
||||
}
|
||||
|
||||
|
@ -373,10 +373,10 @@ func (s *Server) Leave() error {
|
|||
select {
|
||||
case err := <-ch:
|
||||
if err != nil {
|
||||
s.logger.Printf("[ERR] Failed to leave Raft cluster: %v", err)
|
||||
s.logger.Printf("[ERR] consul: failed to leave Raft cluster: %v", err)
|
||||
}
|
||||
case <-time.After(3 * time.Second):
|
||||
s.logger.Printf("[ERR] Timed out leaving Raft cluster")
|
||||
s.logger.Printf("[ERR] consul: timed out leaving Raft cluster")
|
||||
}
|
||||
}
|
||||
AFTER_LEAVE:
|
||||
|
|
Loading…
Reference in New Issue