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 support for replication.enableMajorityReadConcern setting #544

Open
wants to merge 12 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: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,11 @@ class mongodb::server {
}
```

##### `repl_enable_majority_read_concern`
Use this setting to configure replication.enableMajorityReadConcern setting.
For more information please refer to [MongoDB Read Concern "majority"](https://dochub.mongodb.org/core/psa-disable-rc-majority-3.6).
Default: undef (which implies the MongoDB default setting of true)

##### `config_data`
A hash to allow for additional configuration options
to be set in user-provided template.
Expand Down
1 change: 1 addition & 0 deletions manifests/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
Boolean $handle_creds = $mongodb::params::handle_creds,
Boolean $store_creds = $mongodb::params::store_creds,
Array $admin_roles = $mongodb::params::admin_roles,
Optional[Boolean] $repl_enable_majority_read_concern = undef,
Copy link
Member

Choose a reason for hiding this comment

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

Could you make this non optional and default to true? That makes the code here and in the template easier to read.

) inherits mongodb::params {

contain mongodb::server::install
Expand Down
1 change: 1 addition & 0 deletions manifests/server/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
$ssl_invalid_hostnames = $mongodb::server::ssl_invalid_hostnames
$ssl_mode = $mongodb::server::ssl_mode
$storage_engine = $mongodb::server::storage_engine
$repl_enable_majority_read_concern = $mongodb::server::repl_enable_majority_read_concern

File {
owner => $user,
Expand Down
21 changes: 20 additions & 1 deletion spec/classes/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
with_content(%r{^storage\.dbPath: /var/lib/mongodb$}).
with_content(%r{^net\.bindIp: 127\.0\.0\.1$}).
with_content(%r{^systemLog\.logAppend: true$}).
with_content(%r{^systemLog\.path: #{log_path}$})
with_content(%r{^systemLog\.path: #{log_path}$}).
without_content(%r{^replication\.enableMajorityReadConcern:})
end

if facts[:os]['family'] == 'Debian'
Expand Down Expand Up @@ -329,6 +330,24 @@
end
end

describe 'repl_enable_majority_read_concern param' do
context 'set to true' do
let(:params) do
{ repl_enable_majority_read_concern: true }
end

it { is_expected.to contain_file(config_file).with_content(%r{^\s*replication\.enableMajorityReadConcern: true$}) }
end

context 'set to false' do
let(:params) do
{ repl_enable_majority_read_concern: false }
end

it { is_expected.to contain_file(config_file).with_content(%r{^\s*replication\.enableMajorityReadConcern: false$}) }
end
end

context 'when setting up replicasets' do
describe 'should setup using replset_config' do
let(:rsConf) do
Expand Down
3 changes: 3 additions & 0 deletions templates/mongodb.conf.2.6.erb
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ replication.replSetName: <%= @replset %>
<% if @oplog_size -%>
replication.oplogSizeMB: <%= @oplog_size %>
<% end -%>
<% if defined?(@repl_enable_majority_read_concern) -%>
replication.enableMajorityReadConcern: <%= @repl_enable_majority_read_concern %>
<% end -%>

#Sharding
<% if @configsvr -%>
Expand Down