From 69d172a6981d8096bc4ff25716688c3ea4dab93c Mon Sep 17 00:00:00 2001 From: "William G. Korb" Date: Thu, 23 May 2019 16:01:29 -0500 Subject: [PATCH 01/12] Working on adding support for replication.enableMajorityReadConcern setting in mongod.conf. --- README.md | 5 +++++ manifests/server.pp | 1 + manifests/server/config.pp | 1 + templates/mongodb.conf.2.6.erb | 3 +++ 4 files changed, 10 insertions(+) diff --git a/README.md b/README.md index 437c055bc..170736210 100644 --- a/README.md +++ b/README.md @@ -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: true. + ##### `config_data` A hash to allow for additional configuration options to be set in user-provided template. diff --git a/manifests/server.pp b/manifests/server.pp index 007f52f76..6c0f54ec1 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -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, ) inherits mongodb::params { contain mongodb::server::install diff --git a/manifests/server/config.pp b/manifests/server/config.pp index 486af7557..9ea53b2d3 100644 --- a/manifests/server/config.pp +++ b/manifests/server/config.pp @@ -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, diff --git a/templates/mongodb.conf.2.6.erb b/templates/mongodb.conf.2.6.erb index 3da682a77..2ae442564 100644 --- a/templates/mongodb.conf.2.6.erb +++ b/templates/mongodb.conf.2.6.erb @@ -129,6 +129,9 @@ replication.replSetName: <%= @replset %> <% if @oplog_size -%> replication.oplogSizeMB: <%= @oplog_size %> <% end -%> +<% if @repl_enable_majority_read_concern -%> +replication.enableMajorityReadConcern: <%= @repl_enable_majority_read_concern %> +<% end -%> #Sharding <% if @configsvr -%> From 4da13f3e3d622eb16397012f9aa3edde5128f169 Mon Sep 17 00:00:00 2001 From: William Korb Date: Thu, 30 May 2019 22:50:19 -0500 Subject: [PATCH 02/12] Added spec tests for replication.enableMajorityReadConcern. --- README.md | 2 +- spec/classes/server_spec.rb | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 170736210..a6c3ccf23 100644 --- a/README.md +++ b/README.md @@ -464,7 +464,7 @@ 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: true. +Default: true ##### `config_data` A hash to allow for additional configuration options diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index ffeab1355..5ca759107 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -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' @@ -329,6 +330,20 @@ end end + describe 'repl_enable_majority_read_concern param' do + [true, false, undef].each do |value| + context "set to #{value}" do + let (:params) { { :repl_enable_majority_read_concern => value } } + + if value == undef + it { is_expected.to contain_file(config_file).without_content(%r{^replication\.enableMajorityReadConcern:.*$}) } + else + it { should contain_file(config_file).with_content(/^\s*replication\.enableMajorityReadConcern: #{value}$/) } + end + end + end + end + context 'when setting up replicasets' do describe 'should setup using replset_config' do let(:rsConf) do From 8d2137d8da5df4899b4f8e854dd082b5e2aa78dc Mon Sep 17 00:00:00 2001 From: williamkorb Date: Thu, 30 May 2019 22:58:39 -0500 Subject: [PATCH 03/12] Tweaked spec tests for replication.enableMajorityReadConcern. --- spec/classes/server_spec.rb | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index 5ca759107..27c56dcd7 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -331,15 +331,11 @@ end describe 'repl_enable_majority_read_concern param' do - [true, false, undef].each do |value| + [true, false].each do |value| context "set to #{value}" do let (:params) { { :repl_enable_majority_read_concern => value } } - if value == undef - it { is_expected.to contain_file(config_file).without_content(%r{^replication\.enableMajorityReadConcern:.*$}) } - else - it { should contain_file(config_file).with_content(/^\s*replication\.enableMajorityReadConcern: #{value}$/) } - end + it { should contain_file(config_file).with_content(/^\s*replication\.enableMajorityReadConcern: #{value}$/) } end end end From a8bc54857970945a8e5daf37851585a155bea3b3 Mon Sep 17 00:00:00 2001 From: williamkorb Date: Thu, 30 May 2019 23:05:06 -0500 Subject: [PATCH 04/12] Tweaked spec tests for replication.enableMajorityReadConcern. --- spec/classes/server_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index 27c56dcd7..5e3f25a02 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -333,9 +333,9 @@ describe 'repl_enable_majority_read_concern param' do [true, false].each do |value| context "set to #{value}" do - let (:params) { { :repl_enable_majority_read_concern => value } } + let (:params) { { repl_enable_majority_read_concern: #{value} } } - it { should contain_file(config_file).with_content(/^\s*replication\.enableMajorityReadConcern: #{value}$/) } + it { should contain_file(config_file).with_content(%r{^\s*replication\.enableMajorityReadConcern: #{value}$} ) } end end end From c4cf01608090b4afd3b17eee6f1f2dd9c00ac0d2 Mon Sep 17 00:00:00 2001 From: williamkorb Date: Thu, 30 May 2019 23:10:09 -0500 Subject: [PATCH 05/12] Tweaked spec tests for replication.enableMajorityReadConcern. --- spec/classes/server_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index 5e3f25a02..61f2196b0 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -335,7 +335,7 @@ context "set to #{value}" do let (:params) { { repl_enable_majority_read_concern: #{value} } } - it { should contain_file(config_file).with_content(%r{^\s*replication\.enableMajorityReadConcern: #{value}$} ) } + it { is_expected.to contain_file(config_file).with_content(%r{^\s*replication\.enableMajorityReadConcern: #{value}$}) } end end end From 33bb9c70f8f0b6a8e4f85ff2fb75b3dfe6535af2 Mon Sep 17 00:00:00 2001 From: williamkorb Date: Thu, 30 May 2019 23:18:14 -0500 Subject: [PATCH 06/12] Tweaked spec tests for replication.enableMajorityReadConcern. --- spec/classes/server_spec.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index 61f2196b0..fe0368780 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -333,8 +333,10 @@ describe 'repl_enable_majority_read_concern param' do [true, false].each do |value| context "set to #{value}" do - let (:params) { { repl_enable_majority_read_concern: #{value} } } - + let (:params) { + repl_enable_majority_read_concern: #{value} + } + it { is_expected.to contain_file(config_file).with_content(%r{^\s*replication\.enableMajorityReadConcern: #{value}$}) } end end From 0f054386d263eb03778cea1566d5a705aa1a62ae Mon Sep 17 00:00:00 2001 From: williamkorb Date: Thu, 30 May 2019 23:23:06 -0500 Subject: [PATCH 07/12] Tweaked spec tests for replication.enableMajorityReadConcern. --- spec/classes/server_spec.rb | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index fe0368780..854b8a543 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -331,14 +331,20 @@ end describe 'repl_enable_majority_read_concern param' do - [true, false].each do |value| - context "set to #{value}" do - let (:params) { - repl_enable_majority_read_concern: #{value} - } + context "set to true" do + let (:params) { + repl_enable_majority_read_concern: true + } - it { is_expected.to contain_file(config_file).with_content(%r{^\s*replication\.enableMajorityReadConcern: #{value}$}) } - end + it { is_expected.to contain_file(config_file).with_content(%r{^\s*replication\.enableMajorityReadConcern: true$}) } + end + + context "set to false" do + let (:params) { + repl_enable_majority_read_concern: false + } + + it { is_expected.to contain_file(config_file).with_content(%r{^\s*replication\.enableMajorityReadConcern: false$}) } end end From 201d1f26c23b65d0d1ab1d5bf8709884070f5985 Mon Sep 17 00:00:00 2001 From: williamkorb Date: Thu, 30 May 2019 23:26:34 -0500 Subject: [PATCH 08/12] Tweaked spec tests for replication.enableMajorityReadConcern. --- spec/classes/server_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index 854b8a543..47952609c 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -332,17 +332,17 @@ describe 'repl_enable_majority_read_concern param' do context "set to true" do - let (:params) { - repl_enable_majority_read_concern: true - } + 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) { - repl_enable_majority_read_concern: false - } + 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 From 3ad9de20979902d04a8fdc6c8ce75f09e1bcd183 Mon Sep 17 00:00:00 2001 From: williamkorb Date: Thu, 30 May 2019 23:41:55 -0500 Subject: [PATCH 09/12] Tweaked template for replication.enableMajorityReadConcern. --- templates/mongodb.conf.2.6.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/mongodb.conf.2.6.erb b/templates/mongodb.conf.2.6.erb index 2ae442564..b39884451 100644 --- a/templates/mongodb.conf.2.6.erb +++ b/templates/mongodb.conf.2.6.erb @@ -129,7 +129,7 @@ replication.replSetName: <%= @replset %> <% if @oplog_size -%> replication.oplogSizeMB: <%= @oplog_size %> <% end -%> -<% if @repl_enable_majority_read_concern -%> +<% if defined?(@repl_enable_majority_read_concern) -%> replication.enableMajorityReadConcern: <%= @repl_enable_majority_read_concern %> <% end -%> From 93bc5b5f3f402dd53f7554599c085415bcef7cf7 Mon Sep 17 00:00:00 2001 From: williamkorb Date: Thu, 30 May 2019 23:44:21 -0500 Subject: [PATCH 10/12] Tweaked template for replication.enableMajorityReadConcern. --- spec/classes/server_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index 47952609c..e942cf5f9 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -331,7 +331,7 @@ end describe 'repl_enable_majority_read_concern param' do - context "set to true" do + context 'set to true' do let(:params) do { repl_enable_majority_read_concern: true } end @@ -339,7 +339,7 @@ it { is_expected.to contain_file(config_file).with_content(%r{^\s*replication\.enableMajorityReadConcern: true$}) } end - context "set to false" do + context 'set to false' do let(:params) do { repl_enable_majority_read_concern: false } end From e2804164ac609cc53ea2b463752cac6b18d0a112 Mon Sep 17 00:00:00 2001 From: williamkorb Date: Fri, 31 May 2019 08:38:01 -0500 Subject: [PATCH 11/12] Tweaked spec tests for replication.enableMajorityReadConcern. --- spec/classes/server_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/classes/server_spec.rb b/spec/classes/server_spec.rb index e942cf5f9..4a234d5c3 100644 --- a/spec/classes/server_spec.rb +++ b/spec/classes/server_spec.rb @@ -48,7 +48,7 @@ with_content(%r{^net\.bindIp: 127\.0\.0\.1$}). with_content(%r{^systemLog\.logAppend: true$}). with_content(%r{^systemLog\.path: #{log_path}$}). - without_content(%r{^replication\.enableMajorityReadConcern:.*$}) + without_content(%r{^replication\.enableMajorityReadConcern:}) end if facts[:os]['family'] == 'Debian' From a326d6219b2261faac61a8cd8df0632371c6dc56 Mon Sep 17 00:00:00 2001 From: williamkorb Date: Mon, 3 Jun 2019 09:10:52 -0500 Subject: [PATCH 12/12] Updates for replication.enableMajorityReadConcern after PR comments. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a6c3ccf23..3a878e040 100644 --- a/README.md +++ b/README.md @@ -464,7 +464,7 @@ 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: true +Default: undef (which implies the MongoDB default setting of true) ##### `config_data` A hash to allow for additional configuration options