Skip to content

Commit

Permalink
Support for in-cluster lb
Browse files Browse the repository at this point in the history
  • Loading branch information
TrekkieCoder committed Jul 27, 2023
1 parent 884a787 commit 78c6e7e
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions pkg/agent/manager/loadbalancer/loadbalancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1324,33 +1324,35 @@ loop:
}
}

for _, bgpPeerURL := range m.networkConfig.ExtBGPPeers {
bgpPeer := strings.Split(bgpPeerURL, ":")
if len(bgpPeer) > 2 {
continue
}
if !aliveClient.PeeringOnly {
for _, bgpPeerURL := range m.networkConfig.ExtBGPPeers {
bgpPeer := strings.Split(bgpPeerURL, ":")
if len(bgpPeer) > 2 {
continue
}

bgpRemoteIP := net.ParseIP(bgpPeer[0])
if bgpRemoteIP == nil {
continue
}
bgpRemoteIP := net.ParseIP(bgpPeer[0])
if bgpRemoteIP == nil {
continue
}

asid, err := strconv.ParseInt(bgpPeer[1], 10, 0)
if err != nil || asid == 0 {
continue
}
asid, err := strconv.ParseInt(bgpPeer[1], 10, 0)
if err != nil || asid == 0 {
continue
}

bgpNeighCfg, _ := m.makeLoxiLBBGNeighModel(int(asid), bgpRemoteIP.String())
if err := aliveClient.BGP().CreateNeigh(context.Background(), &bgpNeighCfg); err == nil {
klog.Infof("set-ebgp-neigh(%s:%v) cfg success", bgpRemoteIP.String(), asid)
} else {
klog.Infof("set-ebgp-neigh(%s:%v) cfg - failed (%s)", bgpRemoteIP.String(), asid, err)
if strings.Contains(err.Error(), "connection refused") {
klog.Infof("set-ebgp-neigh(%s:%v) cfg - failed", bgpRemoteIP.String(), asid)
time.Sleep(2 * time.Second)
if !aliveClient.DoBGPCfg {
loxiAliveCh <- aliveClient
aliveClient.DoBGPCfg = true
bgpNeighCfg, _ := m.makeLoxiLBBGNeighModel(int(asid), bgpRemoteIP.String())
if err := aliveClient.BGP().CreateNeigh(context.Background(), &bgpNeighCfg); err == nil {
klog.Infof("set-ebgp-neigh(%s:%v) cfg success", bgpRemoteIP.String(), asid)
} else {
klog.Infof("set-ebgp-neigh(%s:%v) cfg - failed (%s)", bgpRemoteIP.String(), asid, err)
if strings.Contains(err.Error(), "connection refused") {
klog.Infof("set-ebgp-neigh(%s:%v) cfg - failed", bgpRemoteIP.String(), asid)
time.Sleep(2 * time.Second)
if !aliveClient.DoBGPCfg {
loxiAliveCh <- aliveClient
aliveClient.DoBGPCfg = true
}
}
}
}
Expand Down

0 comments on commit 78c6e7e

Please sign in to comment.