K8SPSMDB-1640 change default values for concern and add wtimeout#2436
Conversation
| # readConcern: majority | ||
| # writeConcern: | ||
| # w: majority | ||
| # wtimeout: 5000 |
There was a problem hiding this comment.
We usually set the default values in cr. for wtimeout it is 0
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
I think this is to easily understand what is the current value and to what value to change while looking into the default cr.
| [[ $(jq -r '.defaultReadConcern.level' <<<"$rwc") == "majority" ]] | ||
| [[ $(jq -r '.defaultWriteConcern.w' <<<"$rwc") == "majority" ]] | ||
| [[ $(jq -r '.defaultWriteConcern.wtimeout' <<<"$rwc") == "5000" ]] |
There was a problem hiding this comment.
if something is wrong, these will fail without any message and it'll be very hard to debug
There was a problem hiding this comment.
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 withw+wtimeout). - Extended the Mongo client/controller plumbing to send
wtimeoutviasetDefaultRWConcern. - 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.
| 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"` | ||
| } |
| # defaultRWConcern: | ||
| # readConcern: majority | ||
| # writeConcern: | ||
| # w: majority | ||
| # wtimeout: 0 |
commit: 3b9a992 |
CHANGE DESCRIPTION
Problem:
wtimeoutby adjusting the cr to the following: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
Needs Doc) and QA (Needs QA)?Tests
compare/*-oc.yml)?Config/Logging/Testability