Skip to content

K8SPSMDB-1640 change default values for concern and add wtimeout#2436

Merged
hors merged 6 commits into
mainfrom
K8SPSMDB-1640-followup
Jul 7, 2026
Merged

K8SPSMDB-1640 change default values for concern and add wtimeout#2436
hors merged 6 commits into
mainfrom
K8SPSMDB-1640-followup

Conversation

@gkech

@gkech gkech commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

CHANGE DESCRIPTION

Problem:

  • the linearizable and snapshot  are not supported for defaultRWConcern, we can remove them
  • add support for wtimeout by adjusting the cr to the following:
#  defaultRWConcern:
#    readConcern: majority
#    writeConcern:
#      w: majority
#      wtimeout: 5000

Related PR: #2406

Cause:
Short explanation of the root cause of the issue if applicable.

Solution:
Short explanation of the solution we are providing with this PR.

CHECKLIST

Jira

  • Is the Jira ticket created and referenced properly?
  • Does the Jira ticket have the proper statuses for documentation (Needs Doc) and QA (Needs QA)?
  • Does the Jira ticket link to the proper milestone (Fix Version field)?

Tests

  • Is an E2E test/test case added for the new feature/change?
  • Are unit tests added where appropriate?
  • Are OpenShift compare files changed for E2E tests (compare/*-oc.yml)?

Config/Logging/Testability

  • Are all needed new/changed options added to default YAML files?
  • Are all needed new/changed options added to the Helm Chart?
  • Did we add proper logging messages for operator actions?
  • Did we ensure compatibility with the previous version or cluster upgrade process?
  • Does the change support oldest and newest supported MongoDB version?
  • Does the change support oldest and newest supported Kubernetes version?

@pull-request-size pull-request-size Bot added the size/L 100-499 lines label Jul 6, 2026
@github-actions github-actions Bot added the tests label Jul 6, 2026
@gkech gkech marked this pull request as ready for review July 6, 2026 11:30
Comment thread deploy/cr.yaml Outdated
# readConcern: majority
# writeConcern:
# w: majority
# wtimeout: 5000

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We usually set the default values in cr. for wtimeout it is 0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see in the codebase examples of defaults that are not reflected on the cr like that. Also why to keep them like that? cr.yaml is a reference/demo CR, not a strict mirror of code defaults, right?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is to easily understand what is the current value and to what value to change while looking into the default cr.

@gkech gkech requested a review from eleo007 July 6, 2026 13:02
@hors hors added this to the v1.23.0 milestone Jul 6, 2026
Comment thread e2e-tests/init-deploy/run Outdated
Comment on lines +109 to +111
[[ $(jq -r '.defaultReadConcern.level' <<<"$rwc") == "majority" ]]
[[ $(jq -r '.defaultWriteConcern.w' <<<"$rwc") == "majority" ]]
[[ $(jq -r '.defaultWriteConcern.wtimeout' <<<"$rwc") == "5000" ]]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if something is wrong, these will fail without any message and it'll be very hard to debug

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the operator’s defaultRWConcern configuration to (1) remove unsupported defaultReadConcern levels and (2) support defaultWriteConcern.wtimeout, propagating it through the controller into MongoDB’s setDefaultRWConcern command and validating it via CRD schema updates.

Changes:

  • Updated the CR API/CRD schema for spec.defaultRWConcern (readConcern enum narrowed; writeConcern becomes an object with w + wtimeout).
  • Extended the Mongo client/controller plumbing to send wtimeout via setDefaultRWConcern.
  • Added/updated unit + e2e assertions to validate the applied defaults on-cluster.

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/psmdb/mongo/mongo.go Extends SetDefaultRWConcern command payload to include wtimeout.
pkg/psmdb/mongo/fake/client.go Updates fake client interface to match new SetDefaultRWConcern signature.
pkg/controller/perconaservermongodb/mgo.go Plumbs wtimeout from CR spec into Mongo client calls.
pkg/controller/perconaservermongodb/mgo_test.go Updates unit tests for new writeConcern shape and wtimeout behavior.
pkg/apis/psmdb/v1/psmdb_types.go Changes CR API: restricts readConcern enum; models writeConcern as {w, wtimeout}.
pkg/apis/psmdb/v1/zz_generated.deepcopy.go Updates deepcopy logic for new pointer field types.
config/crd/bases/psmdb.percona.com_perconaservermongodbs.yaml CRD base schema updated for new defaultRWConcern structure.
deploy/crd.yaml Generated CRD manifest updated for new defaultRWConcern structure.
deploy/bundle.yaml Bundle CRD schema updated accordingly.
deploy/cw-bundle.yaml Cloud bundle CRD schema updated accordingly.
deploy/cr.yaml Updates commented example for defaultRWConcern (now structured writeConcern).
e2e-tests/version-service/conf/crd.yaml E2E CRD copy updated for new defaultRWConcern structure.
e2e-tests/init-deploy/conf/another-name-rs0.yml E2E CR updated to set defaultRWConcern.writeConcern.wtimeout.
e2e-tests/init-deploy/run Adds an e2e check that getDefaultRWConcern reflects wtimeout.
Files not reviewed (1)
  • pkg/apis/psmdb/v1/zz_generated.deepcopy.go: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/apis/psmdb/v1/psmdb_types.go
Comment on lines 112 to +116
type DefaultRWConcern struct {
// +kubebuilder:validation:Enum={local,available,majority,linearizable,snapshot}
ReadConcern string `json:"readConcern,omitempty"`
WriteConcern string `json:"writeConcern,omitempty"`
// +kubebuilder:validation:Enum={local,available,majority}
ReadConcern string `json:"readConcern,omitempty"`
WriteConcern *DefaultWriteConcernSpec `json:"writeConcern,omitempty"`
}
Comment thread deploy/cr.yaml
Comment on lines +60 to +64
# defaultRWConcern:
# readConcern: majority
# writeConcern:
# w: majority
# wtimeout: 0
@gkech gkech requested a review from egegunes July 7, 2026 07:50
@JNKPercona

Copy link
Copy Markdown
Collaborator
Test Name Result Time
arbiter passed 00:00:00
balancer passed 00:00:00
cert-management-policy passed 00:00:00
clustersync passed 00:00:00
cross-site-sharded passed 00:00:00
custom-replset-name passed 00:00:00
custom-tls passed 00:00:00
custom-users-roles passed 00:00:00
custom-users-roles-sharded passed 00:00:00
data-at-rest-encryption passed 00:00:00
data-sharded passed 00:00:00
demand-backup passed 00:00:00
demand-backup-eks-credentials-irsa passed 00:00:00
demand-backup-fs passed 00:00:00
demand-backup-if-unhealthy passed 00:00:00
demand-backup-incremental-aws passed 00:00:00
demand-backup-incremental-azure passed 00:00:00
demand-backup-incremental-gcp-native passed 00:00:00
demand-backup-incremental-gcp-s3 passed 00:00:00
demand-backup-incremental-oss-s3 passed 00:00:00
demand-backup-incremental-oss-native passed 00:00:00
demand-backup-incremental-minio passed 00:00:00
demand-backup-incremental-sharded-aws passed 00:00:00
demand-backup-incremental-sharded-azure passed 00:00:00
demand-backup-incremental-sharded-gcp-native passed 00:00:00
demand-backup-incremental-sharded-gcp-s3 passed 00:00:00
demand-backup-incremental-sharded-oss-s3 passed 00:00:00
demand-backup-incremental-sharded-oss-native passed 00:00:00
demand-backup-incremental-sharded-minio passed 00:00:00
demand-backup-logical-minio-native-tls passed 00:00:00
demand-backup-physical-parallel passed 00:00:00
demand-backup-physical-aws passed 00:00:00
demand-backup-physical-azure passed 00:00:00
demand-backup-physical-gcp-s3 passed 00:00:00
demand-backup-gcs-workload-identity passed 00:00:00
demand-backup-physical-gcp-native passed 00:00:00
demand-backup-physical-oss-s3 passed 00:00:00
demand-backup-physical-oss-native passed 00:00:00
demand-backup-physical-minio passed 00:00:00
demand-backup-physical-minio-native passed 00:00:00
demand-backup-physical-minio-native-tls passed 00:00:00
demand-backup-physical-sharded-parallel passed 00:00:00
demand-backup-physical-sharded-aws passed 00:00:00
demand-backup-physical-sharded-azure passed 00:00:00
demand-backup-physical-sharded-gcp-native passed 00:00:00
demand-backup-physical-sharded-oss-s3 passed 00:00:00
demand-backup-physical-sharded-oss-native passed 00:00:00
demand-backup-physical-sharded-minio passed 00:00:00
demand-backup-physical-sharded-minio-native passed 00:00:00
demand-backup-sharded passed 00:00:00
demand-backup-snapshot passed 00:00:00
demand-backup-snapshot-vault passed 00:00:00
disabled-auth passed 00:00:00
expose-sharded passed 00:00:00
finalizer passed 00:00:00
ignore-labels-annotations passed 00:00:00
init-deploy passed 00:00:00
ldap passed 00:00:00
ldap-tls passed 00:00:00
limits passed 00:00:00
liveness passed 00:00:00
mongod-major-upgrade passed 00:00:00
mongod-major-upgrade-sharded passed 00:00:00
monitoring-2-0 passed 00:00:00
monitoring-pmm3 passed 00:00:00
multi-cluster-service passed 00:00:00
multi-storage passed 00:00:00
non-voting-and-hidden passed 00:00:00
one-pod passed 00:00:00
operator-self-healing-chaos passed 00:00:00
pitr passed 00:00:00
pitr-physical passed 00:00:00
pitr-sharded passed 00:00:00
pitr-to-new-cluster passed 00:00:00
pitr-physical-backup-source passed 00:00:00
preinit-updates passed 00:00:00
pvc-auto-resize passed 00:00:00
pvc-resize passed 00:00:00
recover-no-primary passed 00:00:00
replset-overrides passed 00:00:00
replset-remapping passed 00:00:00
replset-remapping-sharded passed 00:00:00
rs-shard-migration passed 00:00:00
scaling passed 00:00:00
scheduled-backup passed 00:00:00
security-context passed 00:00:00
self-healing-chaos passed 00:00:00
service-per-pod passed 00:00:00
serviceless-external-nodes passed 00:00:00
smart-update passed 00:00:00
split-horizon passed 00:00:00
split-horizon-manual-tls passed 00:00:00
stable-resource-version passed 00:00:00
storage passed 00:00:00
tls-clusterissuer-cert-manager passed 00:00:00
tls-issue-cert-manager passed 00:00:00
unsafe-psa passed 00:00:00
upgrade passed 00:00:00
upgrade-consistency passed 00:00:00
upgrade-consistency-sharded-tls passed 01:01:04
upgrade-sharded passed 00:00:00
upgrade-partial-backup passed 00:00:00
users passed 00:00:00
users-vault passed 00:00:00
vector-search passed 00:00:00
vector-search-sharded passed 00:00:00
version-service passed 00:00:00
Summary Value
Tests Run 107/107
Job Duration 01:25:54
Total Test Time 01:01:04

commit: 3b9a992
image: perconalab/percona-server-mongodb-operator:PR-2436-3b9a99288

@hors hors merged commit d16fc61 into main Jul 7, 2026
16 checks passed
@hors hors deleted the K8SPSMDB-1640-followup branch July 7, 2026 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/L 100-499 lines tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants