Skip to content

Commit

Permalink
fix(lint): remove non-constant format string (govet)
Browse files Browse the repository at this point in the history
  • Loading branch information
aauren committed Feb 14, 2025
1 parent 48b631c commit 760fcd5
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion pkg/controllers/netpol/network_policy_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ func TestNetworkPolicyBuilder(t *testing.T) {
}
for ipFamily, filterTableRules := range krNetPol.filterTableRules {
for _, np := range netpols {
fmt.Printf(np.policyType)
fmt.Print(np.policyType)
if np.policyType == kubeEgressPolicyType || np.policyType == kubeBothPolicyType {
err = krNetPol.processEgressRules(np, "", nil, "1", ipFamily)
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions pkg/controllers/proxy/network_services_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ func (nsc *NetworkServicesController) Run(healthChan chan<- *healthcheck.Control
// https://github.com/cloudnativelabs/kube-router/issues/282
err = nsc.setupIpvsFirewall()
if err != nil {
klog.Fatalf("error setting up ipvs firewall: %s" + err.Error())
klog.Fatalf("error setting up ipvs firewall: %v", err.Error())
}
nsc.ProxyFirewallSetup.Broadcast()

Expand Down Expand Up @@ -362,7 +362,7 @@ func (nsc *NetworkServicesController) Run(healthChan chan<- *healthcheck.Control
klog.V(1).Info("Performing requested full sync of services")
err = nsc.doSync()
if err != nil {
klog.Errorf("Error during full sync in network service controller. Error: " + err.Error())
klog.Errorf("error during full sync in network service controller. Error: %v", err)
}
case synctypeIpvs:
// We call the component pieces of doSync() here because for methods that send this on the channel they
Expand All @@ -372,11 +372,11 @@ func (nsc *NetworkServicesController) Run(healthChan chan<- *healthcheck.Control
nsc.mu.Lock()
err = nsc.syncIpvsServices(nsc.serviceMap, nsc.endpointsMap)
if err != nil {
klog.Errorf("Error during ipvs sync in network service controller. Error: " + err.Error())
klog.Errorf("error during ipvs sync in network service controller. Error: %v", err)
}
err = nsc.syncHairpinIptablesRules()
if err != nil {
klog.Errorf("Error syncing hairpin iptables rules: %s", err.Error())
klog.Errorf("error syncing hairpin iptables rules: %v", err)
}
nsc.mu.Unlock()
}
Expand All @@ -389,7 +389,7 @@ func (nsc *NetworkServicesController) Run(healthChan chan<- *healthcheck.Control
healthcheck.SendHeartBeat(healthChan, healthcheck.NetworkServicesController)
err := nsc.doSync()
if err != nil {
klog.Errorf("Error during periodic ipvs sync in network service controller. Error: " + err.Error())
klog.Errorf("error during periodic ipvs sync in network service controller. Error: %v", err.Error())
klog.Errorf("Skipping sending heartbeat from network service controller as periodic sync failed.")
} else {
healthcheck.SendHeartBeat(healthChan, healthcheck.NetworkServicesController)
Expand Down Expand Up @@ -1837,7 +1837,7 @@ func (nsc *NetworkServicesController) Cleanup() {
} else {
err = netlink.LinkDel(dummyVipInterface)
if err != nil {
klog.Errorf("Could not delete dummy interface " + KubeDummyIf + " due to " + err.Error())
klog.Errorf("could not delete dummy interface %s due to: %v", KubeDummyIf, err.Error())
return
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/proxy/service_endpoints_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,7 @@ func (nsc *NetworkServicesController) cleanupDSRService(fwMark uint32) error {
mangleTableRulesDump := bytes.Buffer{}
var mangleTableRules []string
if err := utils.SaveInto(iptablesBinary, "mangle", &mangleTableRulesDump); err != nil {
klog.Errorf("Failed to run iptables-save: %s" + err.Error())
klog.Errorf("failed to run iptables-save: %v", err)
} else {
mangleTableRules = strings.Split(mangleTableRulesDump.String(), "\n")
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/controllers/routing/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (nrc *NetworkRoutingController) disableSourceDestinationCheck() {
providerID := strings.Replace(node.Spec.ProviderID, "///", "//", 1)
URL, err := url.Parse(providerID)
if err != nil {
klog.Errorf("Failed to parse URL for providerID " + providerID + " : " + err.Error())
klog.Errorf("failed to parse URL for providerID %s: %v", providerID, err)
return
}
instanceID := URL.Path
Expand All @@ -45,7 +45,7 @@ func (nrc *NetworkRoutingController) disableSourceDestinationCheck() {
metadataClient := ec2metadata.New(sess)
region, err := metadataClient.Region()
if err != nil {
klog.Errorf("Failed to disable source destination check due to: " + err.Error())
klog.Errorf("failed to disable source destination check due to: %v", err)
return
}
sess.Config.Region = aws.String(region)
Expand All @@ -66,9 +66,9 @@ func (nrc *NetworkRoutingController) disableSourceDestinationCheck() {
"disabling src-dst check.")
return
}
klog.Errorf("Failed to disable source destination check due to: %v", err.Error())
klog.Errorf("failed to disable source destination check due to: %v", err)
} else {
klog.Infof("Disabled source destination check for the instance: " + instanceID)
klog.Infof("disabled source destination check for the instance: %s", instanceID)
}

// to prevent EC2 rejecting API call due to API throttling give a delay between the calls
Expand Down
18 changes: 9 additions & 9 deletions pkg/controllers/routing/network_routes_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,8 @@ func (nrc *NetworkRoutingController) Run(healthChan chan<- *healthcheck.Controll
if err == nil {
healthcheck.SendHeartBeat(healthChan, healthcheck.NetworkRoutesController)
} else {
klog.Errorf("Error during periodic sync in network routing controller. Error: " + err.Error())
klog.Errorf("Skipping sending heartbeat from network routing controller as periodic sync failed.")
klog.Errorf("error during periodic sync in network routing controller. Error: %v", err)
klog.Errorf("skipping sending heartbeat from network routing controller as periodic sync failed.")
}

select {
Expand Down Expand Up @@ -461,7 +461,7 @@ func (nrc *NetworkRoutingController) watchBgpUpdates() {
}
klog.V(2).Infof("Processing bgp route advertisement from peer: %s", path.NeighborIp)
if err := nrc.injectRoute(path); err != nil {
klog.Errorf("Failed to inject routes due to: " + err.Error())
klog.Errorf("failed to inject routes due to: %v", err)
}
}
}
Expand All @@ -477,7 +477,7 @@ func (nrc *NetworkRoutingController) watchBgpUpdates() {
},
}, pathWatch)
if err != nil {
klog.Errorf("failed to register monitor global routing table callback due to : " + err.Error())
klog.Errorf("failed to register monitor global routing table callback due to: %v", err)
}
}

Expand Down Expand Up @@ -521,7 +521,7 @@ func (nrc *NetworkRoutingController) advertisePodRoute() error {
},
})
if err != nil {
return fmt.Errorf(err.Error())
return err
}
klog.V(1).Infof("Response from adding path: %s", response)
}
Expand Down Expand Up @@ -567,7 +567,7 @@ func (nrc *NetworkRoutingController) advertisePodRoute() error {
},
})
if err != nil {
return fmt.Errorf(err.Error())
return err
}
klog.V(1).Infof("Response from adding path: %s", response)
}
Expand Down Expand Up @@ -778,11 +778,11 @@ func (nrc *NetworkRoutingController) Cleanup() {
for _, ipset := range nrc.ipSetHandlers {
err = ipset.Save()
if err != nil {
klog.Errorf("Failed to clean up ipsets: " + err.Error())
klog.Errorf("failed to clean up ipsets: %v", err)
}
err = ipset.DestroyAllWithin()
if err != nil {
klog.Warningf("Error deleting ipset: %s", err.Error())
klog.Warningf("error deleting ipset: %v", err)
}
}

Expand Down Expand Up @@ -1074,7 +1074,7 @@ func (nrc *NetworkRoutingController) startBgpServer(grpcServer bool) error {
}

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

go nrc.watchBgpUpdates()
Expand Down
2 changes: 1 addition & 1 deletion pkg/tunnels/linux_tunnels.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func CleanupTunnel(destinationSubnet *net.IPNet, tunnelName string) {
klog.V(1).Infof("Cleaning up any lingering tunnel interfaces named: %s", tunnelName)
if link, err := netlink.LinkByName(tunnelName); err == nil {
if err = netlink.LinkDel(link); err != nil {
klog.Errorf("Failed to delete tunnel link for the node due to " + err.Error())
klog.Errorf("failed to delete tunnel link for the node due to %v", err)
}
}
}
Expand Down

0 comments on commit 760fcd5

Please sign in to comment.