From 694a91c24ec36110adbc6a698a449db1c454d642 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Wed, 7 Aug 2019 08:36:40 +0000 Subject: [PATCH 1/2] =?UTF-8?q?lbagent:=20=E6=94=B9=E6=AD=A3unicast=20vrrp?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/lbagent/api.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/lbagent/api.go b/pkg/lbagent/api.go index 944ad10473..6a362f96db 100644 --- a/pkg/lbagent/api.go +++ b/pkg/lbagent/api.go @@ -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 } From 22468ddebd24b486fed4620157d2d674bed3830b Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Wed, 7 Aug 2019 09:16:02 +0000 Subject: [PATCH 2/2] =?UTF-8?q?lbagent:=20=E6=94=B9=E6=AD=A3agent=E5=8F=82?= =?UTF-8?q?=E6=95=B0=E5=8F=98=E6=9B=B4=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/lbagent/models/agentparams.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/lbagent/models/agentparams.go b/pkg/lbagent/models/agentparams.go index 382b185432..f6e1f9f11d 100644 --- a/pkg/lbagent/models/agentparams.go +++ b/pkg/lbagent/models/agentparams.go @@ -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 }