diff --git a/api/v1/mongodbcommunity_types.go b/api/v1/mongodbcommunity_types.go index 0b33194e8..0dd296c6e 100644 --- a/api/v1/mongodbcommunity_types.go +++ b/api/v1/mongodbcommunity_types.go @@ -132,6 +132,9 @@ type MongoDBCommunitySpec struct { // MemberConfig // +optional MemberConfig []automationconfig.MemberOptions `json:"memberConfig,omitempty"` + + // +optional + CombineDataAndLogsVolumes bool `json:"combineDataAndLogsVolumes,omitempty"` } // MapWrapper is a wrapper for a map to be used by other structs. @@ -1152,7 +1155,7 @@ func (m *MongoDBCommunity) getLastVersion() string { } func (m *MongoDBCommunity) HasSeparateDataAndLogsVolumes() bool { - return true + return !m.Spec.CombineDataAndLogsVolumes } func (m *MongoDBCommunity) GetAnnotations() map[string]string { diff --git a/config/crd/bases/mongodbcommunity.mongodb.com_mongodbcommunity.yaml b/config/crd/bases/mongodbcommunity.mongodb.com_mongodbcommunity.yaml index f62f7465e..462f15cf7 100644 --- a/config/crd/bases/mongodbcommunity.mongodb.com_mongodbcommunity.yaml +++ b/config/crd/bases/mongodbcommunity.mongodb.com_mongodbcommunity.yaml @@ -183,6 +183,8 @@ spec: required: - processes type: object + combineDataAndLogsVolumes: + type: boolean featureCompatibilityVersion: description: FeatureCompatibilityVersion configures the feature compatibility version that will be set for the deployment diff --git a/controllers/replicaset_controller_test.go b/controllers/replicaset_controller_test.go index aac79b07b..ea49d47d2 100644 --- a/controllers/replicaset_controller_test.go +++ b/controllers/replicaset_controller_test.go @@ -1250,6 +1250,21 @@ func TestVolumeClaimTemplates_Configuration(t *testing.T) { assert.Contains(t, pvcSpec.AccessModes, corev1.ReadWriteOnce) } +func TestVolumeClaimCombineTemplates_Configuration(t *testing.T) { + sts, _ := performReconciliationAndGetStatefulSet(t, "data_log_volume_claim_combine_mdb.yaml") + + assert.Len(t, sts.Spec.VolumeClaimTemplates, 1) + + pvcSpec := sts.Spec.VolumeClaimTemplates[0].Spec + + storage := pvcSpec.Resources.Requests[corev1.ResourceStorage] + storageRef := &storage + + assert.Equal(t, "10G", storageRef.String()) + assert.Len(t, pvcSpec.AccessModes, 1) + assert.Contains(t, pvcSpec.AccessModes, corev1.ReadWriteOnce) +} + func TestChangeDataVolume_Configuration(t *testing.T) { sts, _ := performReconciliationAndGetStatefulSet(t, "change_data_volume.yaml") assert.Len(t, sts.Spec.VolumeClaimTemplates, 2) diff --git a/controllers/testdata/data_log_volume_claim_combine_mdb.yaml b/controllers/testdata/data_log_volume_claim_combine_mdb.yaml new file mode 100644 index 000000000..5a91eb1d2 --- /dev/null +++ b/controllers/testdata/data_log_volume_claim_combine_mdb.yaml @@ -0,0 +1,12 @@ +apiVersion: mongodb.com/v1 +kind: MongoDBCommunity +metadata: + name: volume-claim-templates-mdb +spec: + members: 3 + type: ReplicaSet + version: "4.2.6" + security: + authentication: + modes: ["SCRAM"] + combineDataAndLogsVolumes: true \ No newline at end of file