Skip to content

Commit

Permalink
Adjust Node Label Conditions Based on Full Label Name on strechcluster
Browse files Browse the repository at this point in the history
Signed-off-by: Oded Viner <[email protected]>
  • Loading branch information
OdedViner committed Jan 12, 2025
1 parent 0fbee25 commit 2bf7271
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 1 deletion.
19 changes: 19 additions & 0 deletions api/v1/topologymap.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ limitations under the License.
package v1

import (
corev1 "k8s.io/api/core/v1"
"strings"
)

const labelZoneFailureDomainWithoutBeta = "failure-domain.kubernetes.io/zone"

// NewNodeTopologyMap returns an initialized NodeTopologyMap
func NewNodeTopologyMap() *NodeTopologyMap {
return &NodeTopologyMap{
Expand Down Expand Up @@ -76,3 +79,19 @@ func (m *NodeTopologyMap) GetKeyValues(topologyKey string) (string, []string) {

return topologyKey, values
}

// GetKeyValues returns a node label matching the topologyKey and all values for StrechCluster
// for that label across all storage nodes
func (m *NodeTopologyMap) GetKeyValuesStrechCluster() (string, []string) {
values := []string{}
topologyKey := ""
for label, labelValues := range m.Labels {
if label == corev1.LabelZoneFailureDomainStable || label == labelZoneFailureDomainWithoutBeta {
topologyKey = label
values = labelValues
break
}
}

return topologyKey, values
}
2 changes: 1 addition & 1 deletion controllers/storagecluster/cephcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -1068,7 +1068,7 @@ func allowUnsupportedCephVersion() bool {
func generateStretchClusterSpec(sc *ocsv1.StorageCluster) *rookCephv1.StretchClusterSpec {
var zones []string
stretchClusterSpec := rookCephv1.StretchClusterSpec{}
stretchClusterSpec.FailureDomainLabel, zones = sc.Status.NodeTopologies.GetKeyValues(getFailureDomain(sc))
stretchClusterSpec.FailureDomainLabel, zones = sc.Status.NodeTopologies.GetKeyValuesStrechCluster()

for _, zone := range zones {
if zone == sc.Spec.NodeTopologies.ArbiterLocation {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2bf7271

Please sign in to comment.