lbagent: 改正unicast vrrp日志记录

This commit is contained in:
Yousong Zhou
2019-08-07 08:36:40 +00:00
parent 7aa4f83e8a
commit 694a91c24e
+4 -3
View File
@@ -356,19 +356,18 @@ func (h *ApiHelper) doSyncAgentParams(ctx context.Context) bool {
log.Errorf("agent get peers failure: %s", err)
return false
}
useUnicast := true
unicastPeer := []string{}
for _, peer := range peers {
if peer.Id == agent.Id {
continue
}
if peer.IP == "" {
useUnicast = false
log.Warningf("agent %s(%s) has no ip, use multicast vrrp", peer.Name, peer.Id)
break
}
unicastPeer = append(unicastPeer, peer.IP)
}
useUnicast := len(unicastPeer) == len(peers)-1
agentParams, err := agentmodels.NewAgentParams(agent)
if err != nil {
@@ -380,7 +379,9 @@ func (h *ApiHelper) doSyncAgentParams(ctx context.Context) bool {
agentParams.SetVrrpParams("unicast_peer", unicastPeer)
}
if !agentParams.Equals(h.agentParams) {
log.Infof("use unicast vrrp from %s to %s", agent.IP, strings.Join(unicastPeer, ","))
if useUnicast {
log.Infof("use unicast vrrp from %s to %s", agent.IP, strings.Join(unicastPeer, ","))
}
h.agentParams = agentParams
return true
}