mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-06 02:34:03 +00:00
Make tests deal with old and new topology labels
This commit is contained in:
parent
f63ca48a1f
commit
3bd337baf4
@ -15,6 +15,8 @@ metadata:
|
|||||||
cloud.google.com/gke-os-distribution: cos
|
cloud.google.com/gke-os-distribution: cos
|
||||||
failure-domain.beta.kubernetes.io/region: us-central1
|
failure-domain.beta.kubernetes.io/region: us-central1
|
||||||
failure-domain.beta.kubernetes.io/zone: us-central1-b
|
failure-domain.beta.kubernetes.io/zone: us-central1-b
|
||||||
|
topology.kubernetes.io/region: us-central1
|
||||||
|
topology.kubernetes.io/zone: us-central1-b
|
||||||
kubernetes.io/hostname: node-default-pool-something
|
kubernetes.io/hostname: node-default-pool-something
|
||||||
name: node-default-pool-something
|
name: node-default-pool-something
|
||||||
resourceVersion: "211582541"
|
resourceVersion: "211582541"
|
||||||
|
@ -163,6 +163,8 @@ func RestartNodes(c clientset.Interface, nodes []v1.Node) error {
|
|||||||
zone := framework.TestContext.CloudConfig.Zone
|
zone := framework.TestContext.CloudConfig.Zone
|
||||||
if z, ok := node.Labels[v1.LabelFailureDomainBetaZone]; ok {
|
if z, ok := node.Labels[v1.LabelFailureDomainBetaZone]; ok {
|
||||||
zone = z
|
zone = z
|
||||||
|
} else if z, ok := node.Labels[v1.LabelTopologyZone]; ok {
|
||||||
|
zone = z
|
||||||
}
|
}
|
||||||
nodeNamesByZone[zone] = append(nodeNamesByZone[zone], node.Name)
|
nodeNamesByZone[zone] = append(nodeNamesByZone[zone], node.Name)
|
||||||
}
|
}
|
||||||
|
@ -182,6 +182,8 @@ var _ = SIGDescribe("Firewall rule", func() {
|
|||||||
zone := cloudConfig.Zone
|
zone := cloudConfig.Zone
|
||||||
if zoneInLabel, ok := nodeList.Items[0].Labels[v1.LabelFailureDomainBetaZone]; ok {
|
if zoneInLabel, ok := nodeList.Items[0].Labels[v1.LabelFailureDomainBetaZone]; ok {
|
||||||
zone = zoneInLabel
|
zone = zoneInLabel
|
||||||
|
} else if zoneInLabel, ok := nodeList.Items[0].Labels[v1.LabelTopologyZone]; ok {
|
||||||
|
zone = zoneInLabel
|
||||||
}
|
}
|
||||||
removedTags := gce.SetInstanceTags(cloudConfig, nodesNames[0], zone, []string{})
|
removedTags := gce.SetInstanceTags(cloudConfig, nodesNames[0], zone, []string{})
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -23,7 +23,7 @@ import (
|
|||||||
|
|
||||||
"github.com/onsi/ginkgo"
|
"github.com/onsi/ginkgo"
|
||||||
"github.com/onsi/gomega"
|
"github.com/onsi/gomega"
|
||||||
"k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
"k8s.io/apimachinery/pkg/util/intstr"
|
"k8s.io/apimachinery/pkg/util/intstr"
|
||||||
@ -120,13 +120,13 @@ func SpreadServiceOrFail(f *framework.Framework, replicaCount int, image string)
|
|||||||
|
|
||||||
// Find the name of the zone in which a Node is running
|
// Find the name of the zone in which a Node is running
|
||||||
func getZoneNameForNode(node v1.Node) (string, error) {
|
func getZoneNameForNode(node v1.Node) (string, error) {
|
||||||
for key, value := range node.Labels {
|
if z, ok := node.Labels[v1.LabelFailureDomainBetaZone]; ok {
|
||||||
if key == v1.LabelFailureDomainBetaZone {
|
return z, nil
|
||||||
return value, nil
|
} else if z, ok := node.Labels[v1.LabelTopologyZone]; ok {
|
||||||
}
|
return z, nil
|
||||||
}
|
}
|
||||||
return "", fmt.Errorf("node %s doesn't have zone label %s",
|
return "", fmt.Errorf("node %s doesn't have zone label %s or %s",
|
||||||
node.Name, v1.LabelFailureDomainBetaZone)
|
node.Name, v1.LabelFailureDomainBetaZone, v1.LabelTopologyZone)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the number of zones in which we have nodes in this cluster.
|
// Return the number of zones in which we have nodes in this cluster.
|
||||||
|
Loading…
Reference in New Issue
Block a user