Merge pull request #2152 from yousong/bugfix/yousong-lbagent-log-lines

Bugfix/yousong lbagent log lines
This commit is contained in:
yunion-ci-robot
2019-08-07 19:17:54 +08:00
committed by GitHub
2 changed files with 5 additions and 4 deletions
+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
}
+1 -1
View File
@@ -110,7 +110,7 @@ func (p *AgentParams) Equals(p2 *AgentParams) bool {
keys := []string{"notify_script", "unicast_peer"}
for _, key := range keys {
v := p.GetVrrpParams(key)
v2 := p.GetVrrpParams(key)
v2 := p2.GetVrrpParams(key)
if !reflect.DeepEqual(v, v2) {
return false
}