Skip to content

Commit

Permalink
Adjust Node Label Conditions Based on Full Label Name
Browse files Browse the repository at this point in the history
The OCS operator searches for the topology.kubernetes.io/zone
label key using a string containing logic.
If the customer has a node with a label
that includes the string zone.
The OCS operator can read another label containing
'zone' instead of topology.kubernetes.io/zone.

Signed-off-by: Oded Viner <[email protected]>
  • Loading branch information
oviner authored and OdedViner committed Oct 14, 2024
1 parent f80f43b commit 4d3a134
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions controllers/storagecluster/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func setFailureDomain(sc *ocsv1.StorageCluster) {
// If sufficient zones are available then we select zone as the failure domain
topologyMap := sc.Status.NodeTopologies
for label, labelValues := range topologyMap.Labels {
if strings.Contains(label, "zone") {
if label == corev1.LabelZoneFailureDomainStable || label == labelZoneFailureDomainWithoutBeta {
if (len(labelValues) >= 2 && arbiterEnabled(sc)) || (len(labelValues) >= 3) {
failureDomain = "zone"
}
Expand Down Expand Up @@ -135,7 +135,7 @@ func determinePlacementRack(
targetAZ := ""
for label, value := range node.Labels {
for _, key := range validTopologyLabelKeys {
if strings.Contains(label, key) && strings.Contains(label, "zone") {
if strings.Contains(label, key) && (label == corev1.LabelZoneFailureDomainStable || label == labelZoneFailureDomainWithoutBeta) {
targetAZ = value
break
}
Expand All @@ -159,7 +159,7 @@ func determinePlacementRack(
if n.Name == nodeName {
for label, value := range n.Labels {
for _, key := range validTopologyLabelKeys {
if strings.Contains(label, key) && strings.Contains(label, "zone") && value == targetAZ {
if strings.Contains(label, key) && (label == corev1.LabelZoneFailureDomainStable || label == labelZoneFailureDomainWithoutBeta) && value == targetAZ {
validRack = true
break
}
Expand Down

0 comments on commit 4d3a134

Please sign in to comment.