Skip to content

Commit

Permalink
Merge pull request #2983 from openshift-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…2973-to-release-4.18

DFBUGS-1285: [release-4.18] Remove duplicate placements for rook-ceph dameons due to specifying with all & specific key
  • Loading branch information
openshift-merge-bot[bot] authored Jan 29, 2025
2 parents efb257c + 3082120 commit 19d9fa2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 41 deletions.
6 changes: 0 additions & 6 deletions controllers/defaults/placements.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,12 @@ var (
},

"osd": {
Tolerations: []corev1.Toleration{
getOcsToleration(),
},
TopologySpreadConstraints: []corev1.TopologySpreadConstraint{
getTopologySpreadConstraintsSpec(1, []string{osdLabelSelector}),
},
},

"osd-prepare": {
Tolerations: []corev1.Toleration{
getOcsToleration(),
},
TopologySpreadConstraints: []corev1.TopologySpreadConstraint{
getTopologySpreadConstraintsSpec(1, []string{osdLabelSelector, osdPrepareLabelSelector}),
},
Expand Down
42 changes: 16 additions & 26 deletions controllers/storagecluster/cephcluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,34 +539,29 @@ func TestStorageClassDeviceSetCreation(t *testing.T) {
sc3.Spec.LabelSelector = &emptyLabelSelector

cases := []struct {
label string
sc *ocsv1.StorageCluster
topologyKey string
lenOfMatchExpression int
label string
sc *ocsv1.StorageCluster
topologyKey string
}{
{
label: "case 1",
sc: sc1,
topologyKey: "zone",
lenOfMatchExpression: 1,
label: "case 1",
sc: sc1,
topologyKey: "zone",
},
{
label: "case 2",
sc: sc2,
topologyKey: "zone",
lenOfMatchExpression: 1,
label: "case 2",
sc: sc2,
topologyKey: "zone",
},
{
label: "case 3",
sc: sc3,
topologyKey: "zone",
lenOfMatchExpression: 0,
label: "case 3",
sc: sc3,
topologyKey: "zone",
},
{
label: "case 4",
sc: sc4,
topologyKey: "rack",
lenOfMatchExpression: 1,
label: "case 4",
sc: sc4,
topologyKey: "rack",
},
}

Expand Down Expand Up @@ -597,12 +592,7 @@ func TestStorageClassDeviceSetCreation(t *testing.T) {
} else {
assert.DeepEqual(t, getPlacement(c.sc, "osd"), scds.Placement)
}
if c.lenOfMatchExpression == 0 {
assert.Assert(t, is.Nil(scds.Placement.NodeAffinity))
} else {
matchExpressions := scds.Placement.NodeAffinity.RequiredDuringSchedulingIgnoredDuringExecution.NodeSelectorTerms[0].MatchExpressions
assert.Equal(t, c.lenOfMatchExpression, len(matchExpressions))
}

topologyKey := scds.PreparePlacement.TopologySpreadConstraints[0].TopologyKey

if c.topologyKey == "rack" {
Expand Down
5 changes: 4 additions & 1 deletion controllers/storagecluster/placement.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ func getPlacement(sc *ocsv1.StorageCluster, component string) rookCephv1.Placeme
// StorageCluster has no label selector, set the default node
// affinity.
if placement.NodeAffinity == nil && sc.Spec.LabelSelector == nil {
placement.NodeAffinity = defaults.DefaultNodeAffinity
// Don't add node affinity again for these rook-ceph daemons as it is already added via the "all" key
if component != "mgr" && component != "mon" && component != "osd" && component != "osd-prepare" {
placement.NodeAffinity = defaults.DefaultNodeAffinity
}
}

// If the StorageCluster specifies a label selector, append it to the
Expand Down
9 changes: 1 addition & 8 deletions controllers/storagecluster/placement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ func TestGetPlacement(t *testing.T) {
Tolerations: defaults.DaemonPlacements["all"].Tolerations,
},
"mon": {
NodeAffinity: defaults.DefaultNodeAffinity,
PodAntiAffinity: defaults.DaemonPlacements["mon"].PodAntiAffinity,
},
"mds": {
Expand All @@ -196,9 +195,7 @@ func TestGetPlacement(t *testing.T) {
"all": {
NodeAffinity: defaults.DefaultNodeAffinity,
},
"mon": {
NodeAffinity: defaults.DefaultNodeAffinity,
},
"mon": {},
"mds": {
NodeAffinity: defaults.DefaultNodeAffinity,
},
Expand Down Expand Up @@ -323,7 +320,6 @@ func TestGetPlacement(t *testing.T) {
Tolerations: defaults.DaemonPlacements["all"].Tolerations,
},
"mon": {
NodeAffinity: defaults.DefaultNodeAffinity,
PodAntiAffinity: customMONPlacement.PodAntiAffinity,
},
"mds": {
Expand Down Expand Up @@ -389,7 +385,6 @@ func TestGetPlacement(t *testing.T) {
},

"mon": {
NodeAffinity: defaults.DefaultNodeAffinity,
PodAntiAffinity: &corev1.PodAntiAffinity{
RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{
{
Expand Down Expand Up @@ -429,7 +424,6 @@ func TestGetPlacement(t *testing.T) {
Tolerations: defaults.DaemonPlacements["all"].Tolerations,
},
"mon": {
NodeAffinity: defaults.DefaultNodeAffinity,
PodAntiAffinity: &corev1.PodAntiAffinity{},
},
"mds": {
Expand Down Expand Up @@ -475,7 +469,6 @@ func TestGetPlacement(t *testing.T) {
Tolerations: defaults.DaemonPlacements["all"].Tolerations,
},
"mon": {
NodeAffinity: defaults.DefaultNodeAffinity,
Tolerations: []corev1.Toleration{
getOcsToleration(),
},
Expand Down

0 comments on commit 19d9fa2

Please sign in to comment.