Skip to content

Commit c34f404

Browse files
committed
Fixes according to linter
1 parent 62f3f58 commit c34f404

File tree

3 files changed

+300
-97
lines changed

3 files changed

+300
-97
lines changed

pkg/bgp/peer_config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ func validatePeerConfigs(
218218
}
219219
if len(remoteIPs) != len(ports) && len(ports) != 0 {
220220
return fmt.Errorf("invalid peer router config. The number of ports should either be zero, or "+
221-
"one per peer router. If blank items are used, it will default to standard BGP port, %s. ", strconv.Itoa(options.DefaultBgpPort))
221+
"one per peer router. If blank items are used, it will default to standard BGP port, %s. ",
222+
strconv.Itoa(options.DefaultBgpPort))
222223
}
223224
if len(remoteIPs) != len(localIPs) && len(localIPs) != 0 {
224225
return fmt.Errorf("invalid peer router config. The number of localIPs should either be zero, or "+

pkg/controllers/routing/bgp_peers.go

Lines changed: 56 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,13 @@ func (nrc *NetworkRoutingController) syncInternalPeers() {
9393
sourceNodeIsIPv4 := nrc.krNode.GetPrimaryNodeIP().To4() != nil
9494

9595
if targetNodeIsIPv4 != sourceNodeIsIPv4 {
96-
klog.Warningf("Not peering with Node %s as it's primary IP (%s) uses a different protocol than "+
97-
"our primary IP (%s)", node.Name, targetNode.GetPrimaryNodeIP(),
98-
nrc.krNode.GetPrimaryNodeIP())
96+
klog.Warningf(
97+
"Not peering with Node %s as it's primary IP (%s) uses a different protocol than "+
98+
"our primary IP (%s)",
99+
node.Name,
100+
targetNode.GetPrimaryNodeIP(),
101+
nrc.krNode.GetPrimaryNodeIP(),
102+
)
99103
continue
100104
}
101105

@@ -128,7 +132,10 @@ func (nrc *NetworkRoutingController) syncInternalPeers() {
128132
if targetNode.IsIPv4Capable() {
129133
afiSafi := gobgpapi.AfiSafi{
130134
Config: &gobgpapi.AfiSafiConfig{
131-
Family: &gobgpapi.Family{Afi: gobgpapi.Family_AFI_IP, Safi: gobgpapi.Family_SAFI_UNICAST},
135+
Family: &gobgpapi.Family{
136+
Afi: gobgpapi.Family_AFI_IP,
137+
Safi: gobgpapi.Family_SAFI_UNICAST,
138+
},
132139
Enabled: true,
133140
},
134141
MpGracefulRestart: &gobgpapi.MpGracefulRestart{
@@ -143,7 +150,10 @@ func (nrc *NetworkRoutingController) syncInternalPeers() {
143150
if targetNode.IsIPv6Capable() {
144151
afiSafi := gobgpapi.AfiSafi{
145152
Config: &gobgpapi.AfiSafiConfig{
146-
Family: &gobgpapi.Family{Afi: gobgpapi.Family_AFI_IP6, Safi: gobgpapi.Family_SAFI_UNICAST},
153+
Family: &gobgpapi.Family{
154+
Afi: gobgpapi.Family_AFI_IP6,
155+
Safi: gobgpapi.Family_SAFI_UNICAST,
156+
},
147157
Enabled: true,
148158
},
149159
MpGracefulRestart: &gobgpapi.MpGracefulRestart{
@@ -173,7 +183,11 @@ func (nrc *NetworkRoutingController) syncInternalPeers() {
173183
Peer: n,
174184
}); err != nil {
175185
if !strings.Contains(err.Error(), "can't overwrite the existing peer") {
176-
klog.Errorf("Failed to add node %s as peer due to %s", targetNode.GetPrimaryNodeIP(), err)
186+
klog.Errorf(
187+
"Failed to add node %s as peer due to %s",
188+
targetNode.GetPrimaryNodeIP(),
189+
err,
190+
)
177191
}
178192
}
179193
}
@@ -203,8 +217,12 @@ func (nrc *NetworkRoutingController) syncInternalPeers() {
203217
}
204218

205219
// connectToExternalBGPPeers adds all the configured eBGP peers (global or node specific) as neighbours
206-
func (nrc *NetworkRoutingController) connectToExternalBGPPeers(server *gobgp.BgpServer, peerNeighbors []*gobgpapi.Peer,
207-
bgpGracefulRestart bool, bgpGracefulRestartDeferralTime time.Duration, bgpGracefulRestartTime time.Duration,
220+
func (nrc *NetworkRoutingController) connectToExternalBGPPeers(
221+
server *gobgp.BgpServer,
222+
peerNeighbors []*gobgpapi.Peer,
223+
bgpGracefulRestart bool,
224+
bgpGracefulRestartDeferralTime time.Duration,
225+
bgpGracefulRestartTime time.Duration,
208226
peerMultihopTTL uint8,
209227
) error {
210228
for _, n := range peerNeighbors {
@@ -217,16 +235,23 @@ func (nrc *NetworkRoutingController) connectToExternalBGPPeers(server *gobgp.Bgp
217235
}
218236
peeringAddressForNeighbor := net.ParseIP(n.Transport.LocalAddress)
219237
if peeringAddressForNeighbor == nil {
220-
klog.Errorf("unable to parse our local address for peer (%s), not peering with this peer (%s)",
221-
n.Transport.LocalAddress, neighborIPStr)
238+
klog.Errorf(
239+
"unable to parse our local address for peer (%s), not peering with this peer (%s)",
240+
n.Transport.LocalAddress,
241+
neighborIPStr,
242+
)
222243
}
223244

224245
neighborIsIPv4 := neighborIP.To4() != nil
225246
peeringAddressIsIPv4 := peeringAddressForNeighbor.To4() != nil
226247
if neighborIsIPv4 != peeringAddressIsIPv4 {
227-
klog.Warningf("Not peering with configured peer as it's primary IP (%s) uses a different "+
228-
"protocol than our configured local-address (%s). Its possible that this can be resolved by setting "+
229-
"the local address appropriately", neighborIP, peeringAddressForNeighbor)
248+
klog.Warningf(
249+
"Not peering with configured peer as it's primary IP (%s) uses a different "+
250+
"protocol than our configured local-address (%s). Its possible that this can be resolved by setting "+
251+
"the local address appropriately",
252+
neighborIP,
253+
peeringAddressForNeighbor,
254+
)
230255
continue
231256
}
232257

@@ -242,7 +267,10 @@ func (nrc *NetworkRoutingController) connectToExternalBGPPeers(server *gobgp.Bgp
242267
n.AfiSafis = []*gobgpapi.AfiSafi{
243268
{
244269
Config: &gobgpapi.AfiSafiConfig{
245-
Family: &gobgpapi.Family{Afi: gobgpapi.Family_AFI_IP, Safi: gobgpapi.Family_SAFI_UNICAST},
270+
Family: &gobgpapi.Family{
271+
Afi: gobgpapi.Family_AFI_IP,
272+
Safi: gobgpapi.Family_SAFI_UNICAST,
273+
},
246274
Enabled: true,
247275
},
248276
MpGracefulRestart: &gobgpapi.MpGracefulRestart{
@@ -256,7 +284,10 @@ func (nrc *NetworkRoutingController) connectToExternalBGPPeers(server *gobgp.Bgp
256284
if nrc.krNode.IsIPv6Capable() {
257285
afiSafi := gobgpapi.AfiSafi{
258286
Config: &gobgpapi.AfiSafiConfig{
259-
Family: &gobgpapi.Family{Afi: gobgpapi.Family_AFI_IP6, Safi: gobgpapi.Family_SAFI_UNICAST},
287+
Family: &gobgpapi.Family{
288+
Afi: gobgpapi.Family_AFI_IP6,
289+
Safi: gobgpapi.Family_SAFI_UNICAST,
290+
},
260291
Enabled: true,
261292
},
262293
MpGracefulRestart: &gobgpapi.MpGracefulRestart{
@@ -286,7 +317,11 @@ func (nrc *NetworkRoutingController) connectToExternalBGPPeers(server *gobgp.Bgp
286317
}
287318

288319
// Does validation and returns neighbor configs
289-
func newGlobalPeers(peerConfigs bgp.PeerConfigs, holdtime float64, localAddress string) ([]*gobgpapi.Peer, error) {
320+
func newGlobalPeers(
321+
peerConfigs bgp.PeerConfigs,
322+
holdtime float64,
323+
localAddress string,
324+
) []*gobgpapi.Peer {
290325
peers := make([]*gobgpapi.Peer, 0)
291326

292327
ips := peerConfigs.RemoteIPs()
@@ -330,7 +365,7 @@ func newGlobalPeers(peerConfigs bgp.PeerConfigs, holdtime float64, localAddress
330365
peers = append(peers, peer)
331366
}
332367

333-
return peers, nil
368+
return peers
334369
}
335370

336371
func (nrc *NetworkRoutingController) newNodeEventHandler() cache.ResourceEventHandler {
@@ -367,8 +402,10 @@ func (nrc *NetworkRoutingController) newNodeEventHandler() cache.ResourceEventHa
367402
// In this case even if we can't get the NodeIP that's alright as the node is being removed anyway and
368403
// future node lister operations that happen in OnNodeUpdate won't be affected as the node won't be returned
369404
if err == nil && targetNode != nil {
370-
klog.Infof("Received node %s removed update from watch API, so remove node from peer",
371-
targetNode.GetPrimaryNodeIP())
405+
klog.Infof(
406+
"Received node %s removed update from watch API, so remove node from peer",
407+
targetNode.GetPrimaryNodeIP(),
408+
)
372409
} else {
373410
klog.Infof("Received node (IP unavailable) removed update from watch API, so remove node " +
374411
"from peer")

0 commit comments

Comments
 (0)