Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional field to generate log/data pvc #1321

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion api/v1/mongodbcommunity_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions controllers/replicaset_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions controllers/testdata/data_log_volume_claim_combine_mdb.yaml
Original file line number Diff line number Diff line change
@@ -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