Merge pull request #10383 from xu-cheng/topology
osd: ignore the region label when it is the same as zone label in topology
This commit is contained in:
2 files changed
+15
No files matched your search
@@ -93,6 +93,11 @@ func extractTopologyFromLabels(labels map[string]string) (map[string]string, str
|
||||
topologyAffinity = formatTopologyAffinity(corev1.LabelZoneFailureDomainStable, zone)
|
||||
}
|
||||
|
||||
// ignore the region k8s topology label when it has the same value as the k8s zone label
|
||||
if topology[regionLabel] == topology[zoneLabel] {
|
||||
delete(topology, regionLabel)
|
||||
}
|
||||
|
||||
// get host
|
||||
host, ok := labels[corev1.LabelHostname]
|
||||
if ok {
|
||||
|
||||
@@ -134,4 +134,14 @@ func TestTopologyLabels(t *testing.T) {
|
||||
topology, affinity = extractTopologyFromLabels(nodeLabels)
|
||||
assert.Equal(t, 0, len(topology))
|
||||
assert.Equal(t, "", affinity)
|
||||
|
||||
// ignore the region k8s topology label when it has the same value as the k8s zone label
|
||||
nodeLabels = map[string]string{
|
||||
corev1.LabelZoneRegionStable: "zone",
|
||||
corev1.LabelZoneFailureDomainStable: "zone",
|
||||
}
|
||||
topology, affinity = extractTopologyFromLabels(nodeLabels)
|
||||
assert.Equal(t, 1, len(topology))
|
||||
assert.Equal(t, "zone", topology["zone"])
|
||||
assert.Equal(t, "topology.kubernetes.io/zone=zone", affinity)
|
||||
}
|
||||
Reference in new issue
Block a user