Skip to content

Commit 760fcd5

Browse files
committed
fix(lint): remove non-constant format string (govet)
1 parent 48b631c commit 760fcd5

File tree

6 files changed

+22
-22
lines changed

6 files changed

+22
-22
lines changed

pkg/controllers/netpol/network_policy_controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ func TestNetworkPolicyBuilder(t *testing.T) {
574574
}
575575
for ipFamily, filterTableRules := range krNetPol.filterTableRules {
576576
for _, np := range netpols {
577-
fmt.Printf(np.policyType)
577+
fmt.Print(np.policyType)
578578
if np.policyType == kubeEgressPolicyType || np.policyType == kubeBothPolicyType {
579579
err = krNetPol.processEgressRules(np, "", nil, "1", ipFamily)
580580
if err != nil {

pkg/controllers/proxy/network_services_controller.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ func (nsc *NetworkServicesController) Run(healthChan chan<- *healthcheck.Control
319319
// https://github.com/cloudnativelabs/kube-router/issues/282
320320
err = nsc.setupIpvsFirewall()
321321
if err != nil {
322-
klog.Fatalf("error setting up ipvs firewall: %s" + err.Error())
322+
klog.Fatalf("error setting up ipvs firewall: %v", err.Error())
323323
}
324324
nsc.ProxyFirewallSetup.Broadcast()
325325

@@ -362,7 +362,7 @@ func (nsc *NetworkServicesController) Run(healthChan chan<- *healthcheck.Control
362362
klog.V(1).Info("Performing requested full sync of services")
363363
err = nsc.doSync()
364364
if err != nil {
365-
klog.Errorf("Error during full sync in network service controller. Error: " + err.Error())
365+
klog.Errorf("error during full sync in network service controller. Error: %v", err)
366366
}
367367
case synctypeIpvs:
368368
// We call the component pieces of doSync() here because for methods that send this on the channel they
@@ -372,11 +372,11 @@ func (nsc *NetworkServicesController) Run(healthChan chan<- *healthcheck.Control
372372
nsc.mu.Lock()
373373
err = nsc.syncIpvsServices(nsc.serviceMap, nsc.endpointsMap)
374374
if err != nil {
375-
klog.Errorf("Error during ipvs sync in network service controller. Error: " + err.Error())
375+
klog.Errorf("error during ipvs sync in network service controller. Error: %v", err)
376376
}
377377
err = nsc.syncHairpinIptablesRules()
378378
if err != nil {
379-
klog.Errorf("Error syncing hairpin iptables rules: %s", err.Error())
379+
klog.Errorf("error syncing hairpin iptables rules: %v", err)
380380
}
381381
nsc.mu.Unlock()
382382
}
@@ -389,7 +389,7 @@ func (nsc *NetworkServicesController) Run(healthChan chan<- *healthcheck.Control
389389
healthcheck.SendHeartBeat(healthChan, healthcheck.NetworkServicesController)
390390
err := nsc.doSync()
391391
if err != nil {
392-
klog.Errorf("Error during periodic ipvs sync in network service controller. Error: " + err.Error())
392+
klog.Errorf("error during periodic ipvs sync in network service controller. Error: %v", err.Error())
393393
klog.Errorf("Skipping sending heartbeat from network service controller as periodic sync failed.")
394394
} else {
395395
healthcheck.SendHeartBeat(healthChan, healthcheck.NetworkServicesController)
@@ -1837,7 +1837,7 @@ func (nsc *NetworkServicesController) Cleanup() {
18371837
} else {
18381838
err = netlink.LinkDel(dummyVipInterface)
18391839
if err != nil {
1840-
klog.Errorf("Could not delete dummy interface " + KubeDummyIf + " due to " + err.Error())
1840+
klog.Errorf("could not delete dummy interface %s due to: %v", KubeDummyIf, err.Error())
18411841
return
18421842
}
18431843
}

pkg/controllers/proxy/service_endpoints_sync.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ func (nsc *NetworkServicesController) cleanupDSRService(fwMark uint32) error {
824824
mangleTableRulesDump := bytes.Buffer{}
825825
var mangleTableRules []string
826826
if err := utils.SaveInto(iptablesBinary, "mangle", &mangleTableRulesDump); err != nil {
827-
klog.Errorf("Failed to run iptables-save: %s" + err.Error())
827+
klog.Errorf("failed to run iptables-save: %v", err)
828828
} else {
829829
mangleTableRules = strings.Split(mangleTableRulesDump.String(), "\n")
830830
}

pkg/controllers/routing/aws.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (nrc *NetworkRoutingController) disableSourceDestinationCheck() {
3535
providerID := strings.Replace(node.Spec.ProviderID, "///", "//", 1)
3636
URL, err := url.Parse(providerID)
3737
if err != nil {
38-
klog.Errorf("Failed to parse URL for providerID " + providerID + " : " + err.Error())
38+
klog.Errorf("failed to parse URL for providerID %s: %v", providerID, err)
3939
return
4040
}
4141
instanceID := URL.Path
@@ -45,7 +45,7 @@ func (nrc *NetworkRoutingController) disableSourceDestinationCheck() {
4545
metadataClient := ec2metadata.New(sess)
4646
region, err := metadataClient.Region()
4747
if err != nil {
48-
klog.Errorf("Failed to disable source destination check due to: " + err.Error())
48+
klog.Errorf("failed to disable source destination check due to: %v", err)
4949
return
5050
}
5151
sess.Config.Region = aws.String(region)
@@ -66,9 +66,9 @@ func (nrc *NetworkRoutingController) disableSourceDestinationCheck() {
6666
"disabling src-dst check.")
6767
return
6868
}
69-
klog.Errorf("Failed to disable source destination check due to: %v", err.Error())
69+
klog.Errorf("failed to disable source destination check due to: %v", err)
7070
} else {
71-
klog.Infof("Disabled source destination check for the instance: " + instanceID)
71+
klog.Infof("disabled source destination check for the instance: %s", instanceID)
7272
}
7373

7474
// to prevent EC2 rejecting API call due to API throttling give a delay between the calls

pkg/controllers/routing/network_routes_controller.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,8 @@ func (nrc *NetworkRoutingController) Run(healthChan chan<- *healthcheck.Controll
394394
if err == nil {
395395
healthcheck.SendHeartBeat(healthChan, healthcheck.NetworkRoutesController)
396396
} else {
397-
klog.Errorf("Error during periodic sync in network routing controller. Error: " + err.Error())
398-
klog.Errorf("Skipping sending heartbeat from network routing controller as periodic sync failed.")
397+
klog.Errorf("error during periodic sync in network routing controller. Error: %v", err)
398+
klog.Errorf("skipping sending heartbeat from network routing controller as periodic sync failed.")
399399
}
400400

401401
select {
@@ -461,7 +461,7 @@ func (nrc *NetworkRoutingController) watchBgpUpdates() {
461461
}
462462
klog.V(2).Infof("Processing bgp route advertisement from peer: %s", path.NeighborIp)
463463
if err := nrc.injectRoute(path); err != nil {
464-
klog.Errorf("Failed to inject routes due to: " + err.Error())
464+
klog.Errorf("failed to inject routes due to: %v", err)
465465
}
466466
}
467467
}
@@ -477,7 +477,7 @@ func (nrc *NetworkRoutingController) watchBgpUpdates() {
477477
},
478478
}, pathWatch)
479479
if err != nil {
480-
klog.Errorf("failed to register monitor global routing table callback due to : " + err.Error())
480+
klog.Errorf("failed to register monitor global routing table callback due to: %v", err)
481481
}
482482
}
483483

@@ -521,7 +521,7 @@ func (nrc *NetworkRoutingController) advertisePodRoute() error {
521521
},
522522
})
523523
if err != nil {
524-
return fmt.Errorf(err.Error())
524+
return err
525525
}
526526
klog.V(1).Infof("Response from adding path: %s", response)
527527
}
@@ -567,7 +567,7 @@ func (nrc *NetworkRoutingController) advertisePodRoute() error {
567567
},
568568
})
569569
if err != nil {
570-
return fmt.Errorf(err.Error())
570+
return err
571571
}
572572
klog.V(1).Infof("Response from adding path: %s", response)
573573
}
@@ -778,11 +778,11 @@ func (nrc *NetworkRoutingController) Cleanup() {
778778
for _, ipset := range nrc.ipSetHandlers {
779779
err = ipset.Save()
780780
if err != nil {
781-
klog.Errorf("Failed to clean up ipsets: " + err.Error())
781+
klog.Errorf("failed to clean up ipsets: %v", err)
782782
}
783783
err = ipset.DestroyAllWithin()
784784
if err != nil {
785-
klog.Warningf("Error deleting ipset: %s", err.Error())
785+
klog.Warningf("error deleting ipset: %v", err)
786786
}
787787
}
788788

@@ -1074,7 +1074,7 @@ func (nrc *NetworkRoutingController) startBgpServer(grpcServer bool) error {
10741074
}
10751075

10761076
if err := nrc.bgpServer.StartBgp(context.Background(), &gobgpapi.StartBgpRequest{Global: global}); err != nil {
1077-
return errors.New("failed to start BGP server due to : " + err.Error())
1077+
return fmt.Errorf("failed to start BGP server due to: %v", err)
10781078
}
10791079

10801080
go nrc.watchBgpUpdates()

pkg/tunnels/linux_tunnels.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ func CleanupTunnel(destinationSubnet *net.IPNet, tunnelName string) {
256256
klog.V(1).Infof("Cleaning up any lingering tunnel interfaces named: %s", tunnelName)
257257
if link, err := netlink.LinkByName(tunnelName); err == nil {
258258
if err = netlink.LinkDel(link); err != nil {
259-
klog.Errorf("Failed to delete tunnel link for the node due to " + err.Error())
259+
klog.Errorf("failed to delete tunnel link for the node due to %v", err)
260260
}
261261
}
262262
}

0 commit comments

Comments
 (0)