Skip to content

Commit

Permalink
Merge pull request #2215 from Nikhil-Ladha/configure-mon-count
Browse files Browse the repository at this point in the history
Add new field 'monCount' in storagecluster CR
  • Loading branch information
openshift-ci[bot] authored Oct 17, 2023
2 parents 1327f6b + d6ce4a1 commit 417bbd1
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 6 deletions.
2 changes: 2 additions & 0 deletions api/v1/storagecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ type ManagedResourcesSpec struct {
// ManageCephCluster defines how to reconcile the Ceph cluster definition
type ManageCephCluster struct {
ReconcileStrategy string `json:"reconcileStrategy,omitempty"`
// +kubebuilder:validation:Enum=3;5
MonCount int `json:"monCount,omitempty"`
}

// ManageCephConfig defines how to reconcile the Ceph configuration
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/ocs.openshift.io_storageclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,11 @@ spec:
description: ManageCephCluster defines how to reconcile the Ceph
cluster definition
properties:
monCount:
enum:
- 3
- 5
type: integer
reconcileStrategy:
type: string
type: object
Expand Down
15 changes: 10 additions & 5 deletions controllers/storagecluster/cephcluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ func newCephCluster(sc *ocsv1.StorageCluster, cephImage string, nodeCount int, s
Image: cephImage,
AllowUnsupported: allowUnsupportedCephVersion(),
},
Mon: generateMonSpec(sc, nodeCount),
Mon: generateMonSpec(sc),
Mgr: generateMgrSpec(sc),
DataDirHostPath: "/var/lib/rook",
DisruptionManagement: rookCephv1.DisruptionManagementSpec{
Expand Down Expand Up @@ -697,7 +697,7 @@ func getMgrCount(arbiterMode bool) int {
return defaults.DefaultMgrCount
}

func getMonCount(nodeCount int, arbiter bool) int {
func getMonCount(monCount int, arbiter bool) int {
// return static value if overridden
override := os.Getenv(monCountOverrideEnvVar)
if override != "" {
Expand All @@ -712,6 +712,11 @@ func getMonCount(nodeCount int, arbiter bool) int {
if arbiter {
return defaults.ArbiterModeMonCount
}

if monCount != 0 {
return monCount
}

return defaults.DefaultMonCount
}

Expand Down Expand Up @@ -1051,17 +1056,17 @@ func generateStretchClusterSpec(sc *ocsv1.StorageCluster) *rookCephv1.StretchClu
return &stretchClusterSpec
}

func generateMonSpec(sc *ocsv1.StorageCluster, nodeCount int) rookCephv1.MonSpec {
func generateMonSpec(sc *ocsv1.StorageCluster) rookCephv1.MonSpec {
if arbiterEnabled(sc) {
return rookCephv1.MonSpec{
Count: getMonCount(nodeCount, true),
Count: getMonCount(sc.Spec.ManagedResources.CephCluster.MonCount, true),
AllowMultiplePerNode: false,
StretchCluster: generateStretchClusterSpec(sc),
}
}

return rookCephv1.MonSpec{
Count: getMonCount(nodeCount, false),
Count: getMonCount(sc.Spec.ManagedResources.CephCluster.MonCount, false),
AllowMultiplePerNode: statusutil.IsSingleNodeDeployment(),
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ func createFakeScheme(t *testing.T) *runtime.Scheme {
func TestMonCountChange(t *testing.T) {
for nodeCount := 0; nodeCount <= 10; nodeCount++ {
monCountExpected := defaults.DefaultMonCount
monCountActual := getMonCount(nodeCount, false)
monCountActual := getMonCount(0, false)
assert.Equal(t, monCountExpected, monCountActual)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,11 @@ spec:
description: ManageCephCluster defines how to reconcile the Ceph
cluster definition
properties:
monCount:
enum:
- 3
- 5
type: integer
reconcileStrategy:
type: string
type: object
Expand Down
5 changes: 5 additions & 0 deletions deploy/ocs-operator/manifests/storagecluster.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,11 @@ spec:
description: ManageCephCluster defines how to reconcile the Ceph
cluster definition
properties:
monCount:
enum:
- 3
- 5
type: integer
reconcileStrategy:
type: string
type: object
Expand Down

0 comments on commit 417bbd1

Please sign in to comment.