Skip to content

Commit 1d794e9

Browse files
committed
Fix lint errors
Signed-off-by: Riccardo Ravaioli <rravaiol@redhat.com>
1 parent 73bcb02 commit 1d794e9

File tree

2 files changed

+30
-31
lines changed

2 files changed

+30
-31
lines changed

pkg/network/ovn_kubernetes.go

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"github.com/pkg/errors"
2727
appsv1 "k8s.io/api/apps/v1"
2828
corev1 "k8s.io/api/core/v1"
29-
v1 "k8s.io/api/core/v1"
3029
apierrors "k8s.io/apimachinery/pkg/api/errors"
3130
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3231
uns "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
@@ -97,7 +96,7 @@ func renderOVNKubernetes(conf *operv1.NetworkSpec, bootstrapResult *bootstrap.Bo
9796
// For now, return an error since we don't have any master nodes to run the ovnkube-control-plane deployment.
9897
externalControlPlane := bootstrapResult.Infra.ControlPlaneTopology == configv1.ExternalTopologyMode
9998
if externalControlPlane && !bootstrapResult.OVN.OVNKubernetesConfig.HyperShiftConfig.Enabled {
100-
return nil, progressing, fmt.Errorf("Unable to render OVN in a cluster with an external control plane")
99+
return nil, progressing, fmt.Errorf("unable to render OVN in a cluster with an external control plane")
101100
}
102101

103102
c := conf.DefaultNetwork.OVNKubernetesConfig
@@ -941,7 +940,7 @@ func bootstrapOVNConfig(conf *operv1.Network, kubeClient cnoclient.Client, hc *h
941940

942941
if err != nil {
943942
if !apierrors.IsNotFound(err) {
944-
return nil, fmt.Errorf("Could not determine Node Mode: %w", err)
943+
return nil, fmt.Errorf("could not determine Node Mode: %w", err)
945944
}
946945
} else {
947946
dpuHostModeLabel, exists := cm.Data["dpu-host-mode-label"]
@@ -981,40 +980,40 @@ func bootstrapOVNConfig(conf *operv1.Network, kubeClient cnoclient.Client, hc *h
981980
// daemonset pods in DPU mode from running), it is done by an external operator.
982981
ovnConfigResult.DpuHostModeNodes, err = getNodeListByLabel(kubeClient, ovnConfigResult.DpuHostModeLabel)
983982
if err != nil {
984-
return nil, fmt.Errorf("Could not get node list with label %s : %w", ovnConfigResult.DpuHostModeLabel, err)
983+
return nil, fmt.Errorf("could not get node list with label %s : %w", ovnConfigResult.DpuHostModeLabel, err)
985984
}
986985
ovnConfigResult.DpuHostModeLabel, ovnConfigResult.DpuHostModeValue, err = getKeyValueFromLabel(ovnConfigResult.DpuHostModeLabel)
987986
if err != nil {
988-
return nil, fmt.Errorf("Could not get key and value from label %s : %w", ovnConfigResult.DpuHostModeLabel, err)
987+
return nil, fmt.Errorf("could not get key and value from label %s : %w", ovnConfigResult.DpuHostModeLabel, err)
989988
}
990989

991990
ovnConfigResult.DpuModeNodes, err = getNodeListByLabel(kubeClient, ovnConfigResult.DpuModeLabel)
992991
if err != nil {
993-
return nil, fmt.Errorf("Could not get node list with label %s : %w", ovnConfigResult.DpuModeLabel, err)
992+
return nil, fmt.Errorf("could not get node list with label %s : %w", ovnConfigResult.DpuModeLabel, err)
994993
}
995994
ovnConfigResult.DpuModeLabel, _, err = getKeyValueFromLabel(ovnConfigResult.DpuModeLabel)
996995
if err != nil {
997-
return nil, fmt.Errorf("Could not get key and value from label %s : %w", ovnConfigResult.DpuModeLabel, err)
996+
return nil, fmt.Errorf("could not get key and value from label %s : %w", ovnConfigResult.DpuModeLabel, err)
998997
}
999998

1000999
ovnConfigResult.SmartNicModeNodes, err = getNodeListByLabel(kubeClient, ovnConfigResult.SmartNicModeLabel)
10011000
if err != nil {
1002-
return nil, fmt.Errorf("Could not get node list with label %s : %w", ovnConfigResult.SmartNicModeLabel, err)
1001+
return nil, fmt.Errorf("could not get node list with label %s : %w", ovnConfigResult.SmartNicModeLabel, err)
10031002
}
10041003
ovnConfigResult.SmartNicModeLabel, ovnConfigResult.SmartNicModeValue, err = getKeyValueFromLabel(ovnConfigResult.SmartNicModeLabel)
10051004
if err != nil {
1006-
return nil, fmt.Errorf("Could not get key and value from label %s : %w", ovnConfigResult.SmartNicModeLabel, err)
1005+
return nil, fmt.Errorf("could not get key and value from label %s : %w", ovnConfigResult.SmartNicModeLabel, err)
10071006
}
10081007

10091008
// No node shall have any other label set. Each node should be ONLY be DPU, DPU Host, or Smart NIC.
10101009
found, nodeName := findCommonNode(ovnConfigResult.DpuHostModeNodes, ovnConfigResult.DpuModeNodes, ovnConfigResult.SmartNicModeNodes)
10111010
if found {
1012-
return nil, fmt.Errorf("Node %s has multiple hardware offload labels.", nodeName)
1011+
return nil, fmt.Errorf("node %s has multiple hardware offload labels", nodeName)
10131012
}
10141013

10151014
ovnConfigResult.ConfigOverrides, err = getOVNKubernetesConfigOverrides(kubeClient)
10161015
if err != nil {
1017-
return nil, fmt.Errorf("Could not get OVN Kubernetes config overrides: %w", err)
1016+
return nil, fmt.Errorf("could not get OVN Kubernetes config overrides: %w", err)
10181017
}
10191018

10201019
klog.Infof("OVN configuration is now %+v", ovnConfigResult)
@@ -1249,18 +1248,18 @@ func bootstrapOVN(conf *operv1.Network, kubeClient cnoclient.Client, infraStatus
12491248
clusterConfigLookup := types.NamespacedName{Name: CLUSTER_CONFIG_NAME, Namespace: CLUSTER_CONFIG_NAMESPACE}
12501249

12511250
if err := kubeClient.ClientFor("").CRClient().Get(context.TODO(), clusterConfigLookup, clusterConfig); err != nil {
1252-
return nil, fmt.Errorf("Unable to bootstrap OVN, unable to retrieve cluster config: %s", err)
1251+
return nil, fmt.Errorf("unable to bootstrap OVN, unable to retrieve cluster config: %s", err)
12531252
}
12541253

12551254
rcD := replicaCountDecoder{}
12561255
if err := yaml.Unmarshal([]byte(clusterConfig.Data["install-config"]), &rcD); err != nil {
1257-
return nil, fmt.Errorf("Unable to bootstrap OVN, unable to unmarshal install-config: %s", err)
1256+
return nil, fmt.Errorf("unable to bootstrap OVN, unable to unmarshal install-config: %s", err)
12581257
}
12591258

12601259
hc := hypershift.NewHyperShiftConfig()
12611260
ovnConfigResult, err := bootstrapOVNConfig(conf, kubeClient, hc, infraStatus)
12621261
if err != nil {
1263-
return nil, fmt.Errorf("Unable to bootstrap OVN config, err: %v", err)
1262+
return nil, fmt.Errorf("unable to bootstrap OVN config, err: %v", err)
12641263
}
12651264

12661265
var controlPlaneReplicaCount int
@@ -1295,7 +1294,7 @@ func bootstrapOVN(conf *operv1.Network, kubeClient cnoclient.Client, infraStatus
12951294
nsn = types.NamespacedName{Namespace: namespaceForControlPlane, Name: util.OVN_CONTROL_PLANE}
12961295
if err := clusterClientForControlPlane.CRClient().Get(context.TODO(), nsn, controlPlaneDeployment); err != nil {
12971296
if !apierrors.IsNotFound(err) {
1298-
return nil, fmt.Errorf("Failed to retrieve %s deployment: %w", util.OVN_CONTROL_PLANE, err)
1297+
return nil, fmt.Errorf("failed to retrieve %s deployment: %w", util.OVN_CONTROL_PLANE, err)
12991298
} else {
13001299
klog.Infof("%s deployment not running", util.OVN_CONTROL_PLANE)
13011300
controlPlaneStatus = nil
@@ -1324,7 +1323,7 @@ func bootstrapOVN(conf *operv1.Network, kubeClient cnoclient.Client, infraStatus
13241323
nsn = types.NamespacedName{Namespace: util.OVN_NAMESPACE, Name: util.OVN_NODE}
13251324
if err := kubeClient.ClientFor("").CRClient().Get(context.TODO(), nsn, nodeDaemonSet); err != nil {
13261325
if !apierrors.IsNotFound(err) {
1327-
return nil, fmt.Errorf("Failed to retrieve existing ovnkube-node DaemonSet: %w", err)
1326+
return nil, fmt.Errorf("failed to retrieve existing ovnkube-node DaemonSet: %w", err)
13281327
} else {
13291328
nodeStatus = nil
13301329
klog.Infof("ovnkube-node DaemonSet not running")
@@ -1353,7 +1352,7 @@ func bootstrapOVN(conf *operv1.Network, kubeClient cnoclient.Client, infraStatus
13531352
nsn = types.NamespacedName{Namespace: util.OVN_NAMESPACE, Name: "ovnkube-upgrades-prepuller"}
13541353
if err := kubeClient.ClientFor("").CRClient().Get(context.TODO(), nsn, prePullerDaemonSet); err != nil {
13551354
if !apierrors.IsNotFound(err) {
1356-
return nil, fmt.Errorf("Failed to retrieve existing prepuller DaemonSet: %w", err)
1355+
return nil, fmt.Errorf("failed to retrieve existing prepuller DaemonSet: %w", err)
13571356
} else {
13581357
prepullerStatus = nil
13591358
}
@@ -1891,7 +1890,7 @@ func isOVNIPsecNotActiveInDaemonSet(ds *appsv1.DaemonSet) bool {
18911890
return true
18921891
}
18931892

1894-
func isIPSecEnabledInPod(pod v1.PodTemplateSpec, containerName string) bool {
1893+
func isIPSecEnabledInPod(pod corev1.PodTemplateSpec, containerName string) bool {
18951894
for _, container := range pod.Spec.Containers {
18961895
if container.Name == containerName {
18971896
for _, c := range container.Lifecycle.PostStart.Exec.Command {
@@ -2042,7 +2041,7 @@ func validateOVNKubernetesSubnet(name, subnet string, otherSubnets *iputil.IPPoo
20422041
}
20432042
}
20442043
if err := otherSubnets.Add(*cidr); err != nil {
2045-
return fmt.Errorf("Whole or subset of %s CIDR %s is already in use: %s", name, subnet, err)
2044+
return fmt.Errorf("whole or subset of %s CIDR %s is already in use: %s", name, subnet, err)
20462045
}
20472046
return nil
20482047
}

pkg/network/ovn_kubernetes_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,20 +1199,20 @@ func TestValidateOVNKubernetesSubnetsIPv4(t *testing.T) {
11991199
// IPv4 subnet overlap check
12001200
ovnConfig.V4InternalSubnet = ""
12011201
ovnConfig.IPv4.InternalJoinSubnet = "10.128.0.0/16"
1202-
errExpect("Whole or subset of v4InternalJoinSubnet CIDR 10.128.0.0/16 is already in use: CIDRs 10.128.0.0/15 and 10.128.0.0/16 overlap")
1202+
errExpect("whole or subset of v4InternalJoinSubnet CIDR 10.128.0.0/16 is already in use: CIDRs 10.128.0.0/15 and 10.128.0.0/16 overlap")
12031203
ovnConfig.IPv4.InternalTransitSwitchSubnet = "10.128.0.0/16"
1204-
errExpect("Whole or subset of v4InternalTransitSwitchSubnet CIDR 10.128.0.0/16 is already in use: CIDRs 10.128.0.0/15 and 10.128.0.0/16 overlap")
1204+
errExpect("whole or subset of v4InternalTransitSwitchSubnet CIDR 10.128.0.0/16 is already in use: CIDRs 10.128.0.0/15 and 10.128.0.0/16 overlap")
12051205
ovnConfig.GatewayConfig.IPv4.InternalMasqueradeSubnet = "10.128.0.0/16"
1206-
errExpect("Whole or subset of v4InternalMasqueradeSubnet CIDR 10.128.0.0/16 is already in use: CIDRs 10.128.0.0/15 and 10.128.0.0/16 overlap")
1206+
errExpect("whole or subset of v4InternalMasqueradeSubnet CIDR 10.128.0.0/16 is already in use: CIDRs 10.128.0.0/15 and 10.128.0.0/16 overlap")
12071207
ovnConfig.IPv4.InternalJoinSubnet = "100.99.0.0/16"
12081208
ovnConfig.GatewayConfig.IPv4.InternalMasqueradeSubnet = "100.99.0.0/16"
1209-
errExpect("Whole or subset of v4InternalMasqueradeSubnet CIDR 100.99.0.0/16 is already in use: CIDRs 100.99.0.0/16 and 100.99.0.0/16 overlap")
1209+
errExpect("whole or subset of v4InternalMasqueradeSubnet CIDR 100.99.0.0/16 is already in use: CIDRs 100.99.0.0/16 and 100.99.0.0/16 overlap")
12101210
ovnConfig.IPv4.InternalJoinSubnet = "100.99.0.0/16"
12111211
ovnConfig.IPv4.InternalTransitSwitchSubnet = "100.99.0.0/16"
1212-
errExpect("Whole or subset of v4InternalTransitSwitchSubnet CIDR 100.99.0.0/16 is already in use: CIDRs 100.99.0.0/16 and 100.99.0.0/16 overlap")
1212+
errExpect("whole or subset of v4InternalTransitSwitchSubnet CIDR 100.99.0.0/16 is already in use: CIDRs 100.99.0.0/16 and 100.99.0.0/16 overlap")
12131213
ovnConfig.IPv4.InternalTransitSwitchSubnet = "100.99.0.0/16"
12141214
ovnConfig.GatewayConfig.IPv4.InternalMasqueradeSubnet = "100.99.0.0/16"
1215-
errExpect("Whole or subset of v4InternalMasqueradeSubnet CIDR 100.99.0.0/16 is already in use: CIDRs 100.99.0.0/16 and 100.99.0.0/16 overlap")
1215+
errExpect("whole or subset of v4InternalMasqueradeSubnet CIDR 100.99.0.0/16 is already in use: CIDRs 100.99.0.0/16 and 100.99.0.0/16 overlap")
12161216
}
12171217

12181218
func TestValidateOVNKubernetesSubnetsIPv6(t *testing.T) {
@@ -1282,20 +1282,20 @@ func TestValidateOVNKubernetesSubnetsIPv6(t *testing.T) {
12821282
// IPv6 subnet overlap check
12831283
ovnConfig.V6InternalSubnet = ""
12841284
ovnConfig.IPv6.InternalJoinSubnet = "fd01::/64"
1285-
errExpect("Whole or subset of v6InternalJoinSubnet CIDR fd01::/64 is already in use: CIDRs fd01::/48 and fd01::/64 overlap")
1285+
errExpect("whole or subset of v6InternalJoinSubnet CIDR fd01::/64 is already in use: CIDRs fd01::/48 and fd01::/64 overlap")
12861286
ovnConfig.IPv6.InternalTransitSwitchSubnet = "fd01::/64"
1287-
errExpect("Whole or subset of v6InternalTransitSwitchSubnet CIDR fd01::/64 is already in use: CIDRs fd01::/48 and fd01::/64 overlap")
1287+
errExpect("whole or subset of v6InternalTransitSwitchSubnet CIDR fd01::/64 is already in use: CIDRs fd01::/48 and fd01::/64 overlap")
12881288
ovnConfig.GatewayConfig.IPv6.InternalMasqueradeSubnet = "fd01::/64"
1289-
errExpect("Whole or subset of v6InternalMasqueradeSubnet CIDR fd01::/64 is already in use: CIDRs fd01::/48 and fd01::/64 overlap")
1289+
errExpect("whole or subset of v6InternalMasqueradeSubnet CIDR fd01::/64 is already in use: CIDRs fd01::/48 and fd01::/64 overlap")
12901290
ovnConfig.IPv6.InternalJoinSubnet = "fd69::/111"
12911291
ovnConfig.GatewayConfig.IPv6.InternalMasqueradeSubnet = "fd69::/111"
1292-
errExpect("Whole or subset of v6InternalMasqueradeSubnet CIDR fd69::/111 is already in use: CIDRs fd69::/111 and fd69::/111 overlap")
1292+
errExpect("whole or subset of v6InternalMasqueradeSubnet CIDR fd69::/111 is already in use: CIDRs fd69::/111 and fd69::/111 overlap")
12931293
ovnConfig.IPv6.InternalJoinSubnet = "fd69::/111"
12941294
ovnConfig.IPv6.InternalTransitSwitchSubnet = "fd69::/111"
1295-
errExpect("Whole or subset of v6InternalTransitSwitchSubnet CIDR fd69::/111 is already in use: CIDRs fd69::/111 and fd69::/111 overlap")
1295+
errExpect("whole or subset of v6InternalTransitSwitchSubnet CIDR fd69::/111 is already in use: CIDRs fd69::/111 and fd69::/111 overlap")
12961296
ovnConfig.IPv6.InternalTransitSwitchSubnet = "fd69::/111"
12971297
ovnConfig.GatewayConfig.IPv6.InternalMasqueradeSubnet = "fd69::/111"
1298-
errExpect("Whole or subset of v6InternalMasqueradeSubnet CIDR fd69::/111 is already in use: CIDRs fd69::/111 and fd69::/111 overlap")
1298+
errExpect("whole or subset of v6InternalMasqueradeSubnet CIDR fd69::/111 is already in use: CIDRs fd69::/111 and fd69::/111 overlap")
12991299
}
13001300

13011301
func TestValidateOVNKubernetesDualStack(t *testing.T) {

0 commit comments

Comments
 (0)