Skip to content

Commit

Permalink
connectivity/check: use existing label constants from corev1
Browse files Browse the repository at this point in the history
Use the predefined corev1 constants instead of open-coding them.

Signed-off-by: Tobias Klauser <[email protected]>
  • Loading branch information
tklauser committed Apr 28, 2023
1 parent e686037 commit 138d415
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions connectivity/check/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,13 +399,12 @@ func (ct *ConnectivityTest) deploy(ctx context.Context) error {
return fmt.Errorf("unable to query nodes")
}
for _, l := range n.Items {
if _, ok := zones[l.GetLabels()["topology.kubernetes.io/zone"]]; ok {
zone = l.GetLabels()["topology.kubernetes.io/zone"]
if _, ok := zones[l.GetLabels()[corev1.LabelTopologyZone]]; ok {
zone = l.GetLabels()[corev1.LabelTopologyZone]
break
}

zones[l.GetLabels()["topology.kubernetes.io/zone"]] = 1
lz = l.GetLabels()["topology.kubernetes.io/zone"]
zones[l.GetLabels()[corev1.LabelTopologyZone]] = 1
lz = l.GetLabels()[corev1.LabelTopologyZone]
}
// No zone had > 1, use the last zone.
if zone == "" {
Expand Down Expand Up @@ -440,7 +439,7 @@ func (ct *ConnectivityTest) deploy(ctx context.Context) error {
Weight: 100,
Preference: corev1.NodeSelectorTerm{
MatchExpressions: []corev1.NodeSelectorRequirement{
{Key: "topology.kubernetes.io/zone", Operator: corev1.NodeSelectorOpIn, Values: []string{zone}},
{Key: corev1.LabelTopologyZone, Operator: corev1.NodeSelectorOpIn, Values: []string{zone}},
},
},
},
Expand Down Expand Up @@ -479,7 +478,7 @@ func (ct *ConnectivityTest) deploy(ctx context.Context) error {
Weight: 100,
Preference: corev1.NodeSelectorTerm{
MatchExpressions: []corev1.NodeSelectorRequirement{
{Key: "topology.kubernetes.io/zone", Operator: corev1.NodeSelectorOpIn, Values: []string{zone}},
{Key: corev1.LabelTopologyZone, Operator: corev1.NodeSelectorOpIn, Values: []string{zone}},
},
},
},
Expand All @@ -493,7 +492,7 @@ func (ct *ConnectivityTest) deploy(ctx context.Context) error {
{Key: "name", Operator: metav1.LabelSelectorOpIn, Values: []string{nm.ClientName()}},
},
},
TopologyKey: "kubernetes.io/hostname",
TopologyKey: corev1.LabelHostname,
},
},
},
Expand Down Expand Up @@ -533,7 +532,7 @@ func (ct *ConnectivityTest) deploy(ctx context.Context) error {
Weight: 100,
Preference: corev1.NodeSelectorTerm{
MatchExpressions: []corev1.NodeSelectorRequirement{
{Key: "topology.kubernetes.io/zone", Operator: corev1.NodeSelectorOpIn, Values: []string{zone}},
{Key: corev1.LabelTopologyZone, Operator: corev1.NodeSelectorOpIn, Values: []string{zone}},
},
},
},
Expand All @@ -544,7 +543,7 @@ func (ct *ConnectivityTest) deploy(ctx context.Context) error {
{Weight: 100, PodAffinityTerm: corev1.PodAffinityTerm{
LabelSelector: &metav1.LabelSelector{MatchExpressions: []metav1.LabelSelectorRequirement{
{Key: "name", Operator: metav1.LabelSelectorOpIn, Values: []string{nm.ClientName()}}}},
TopologyKey: "kubernetes.io/hostname"}}}},
TopologyKey: corev1.LabelHostname}}}},
},
NodeSelector: ct.params.NodeSelector,
HostNetwork: ct.params.PerfHostNet,
Expand Down Expand Up @@ -662,7 +661,7 @@ func (ct *ConnectivityTest) deploy(ctx context.Context) error {
{Key: "name", Operator: metav1.LabelSelectorOpIn, Values: []string{clientDeploymentName}},
},
},
TopologyKey: "kubernetes.io/hostname",
TopologyKey: corev1.LabelHostname,
},
},
},
Expand Down Expand Up @@ -722,7 +721,7 @@ func (ct *ConnectivityTest) deploy(ctx context.Context) error {
{Key: "name", Operator: metav1.LabelSelectorOpIn, Values: []string{clientDeploymentName}},
},
},
TopologyKey: "kubernetes.io/hostname",
TopologyKey: corev1.LabelHostname,
},
},
},
Expand Down Expand Up @@ -778,7 +777,7 @@ func (ct *ConnectivityTest) deploy(ctx context.Context) error {
{Key: "name", Operator: metav1.LabelSelectorOpIn, Values: []string{clientDeploymentName}},
},
},
TopologyKey: "kubernetes.io/hostname",
TopologyKey: corev1.LabelHostname,
},
},
},
Expand Down

0 comments on commit 138d415

Please sign in to comment.