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 9f8e66d
Show file tree
Hide file tree
Showing 2 changed files with 20 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()

Check failure on line 1071 in controllers/storagecluster/cephcluster.go

View workflow job for this annotation

GitHub Actions / go test (1.23)

sc.Status.NodeTopologies.GetKeyValuesStrechCluster undefined (type *"github.com/red-hat-storage/ocs-operator/api/v4/v1".NodeTopologyMap has no field or method GetKeyValuesStrechCluster)

Check failure on line 1071 in controllers/storagecluster/cephcluster.go

View workflow job for this annotation

GitHub Actions / golangci-lint (1.23)

sc.Status.NodeTopologies.GetKeyValuesStrechCluster undefined (type *"github.com/red-hat-storage/ocs-operator/api/v4/v1".NodeTopologyMap has no field or method GetKeyValuesStrechCluster)) (typecheck)

Check failure on line 1071 in controllers/storagecluster/cephcluster.go

View workflow job for this annotation

GitHub Actions / golangci-lint (1.23)

sc.Status.NodeTopologies.GetKeyValuesStrechCluster undefined (type *"github.com/red-hat-storage/ocs-operator/api/v4/v1".NodeTopologyMap has no field or method GetKeyValuesStrechCluster)) (typecheck)

Check failure on line 1071 in controllers/storagecluster/cephcluster.go

View workflow job for this annotation

GitHub Actions / golangci-lint (1.23)

sc.Status.NodeTopologies.GetKeyValuesStrechCluster undefined (type *"github.com/red-hat-storage/ocs-operator/api/v4/v1".NodeTopologyMap has no field or method GetKeyValuesStrechCluster) (typecheck)

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

0 comments on commit 9f8e66d

Please sign in to comment.