Skip to content

Commit

Permalink
Fix two_nodes behaviour with expected_votes = 2
Browse files Browse the repository at this point in the history
commit 9a54a5c introduced a wrong
behaviour: when expected_votes is 2, then two_nodes should be set to 1,
even  if you do not specify quorum_members

Signed-off-by: Julien Pivotto <[email protected]>
  • Loading branch information
roidelapluie committed Sep 5, 2016
1 parent 16db14e commit 24a098f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Those parameters can now be specified as class parameters. (#345)
- Removed legacy configuration sections: amf, aisexec, logging.logger\_subsys
(#345)
- Fix two\_nodes behaviour with expected\_votes = 2 introduced in 3.0.0 (#246)

### Deprecation notes

Expand Down
16 changes: 15 additions & 1 deletion spec/classes/corosync_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
before do
params.merge!(
quorum_members: ['node1.test.org', 'node2.test.org', 'node3.test.org'],
votequorum_expected_votes: 2
votequorum_expected_votes: 3
)
end

Expand All @@ -67,6 +67,20 @@
end
end

context 'when quorum_members is not set and votequorum_expected_votes is set' do
before do
params.merge!(
votequorum_expected_votes: 2
)
end

it 'configures two_node' do
should contain_file('/etc/corosync/corosync.conf').with_content(
%r{two_node: 1}
)
end
end

context 'when 2 quorum_members are set and votequorum_expected_votes is set' do
before do
params.merge!(
Expand Down
5 changes: 4 additions & 1 deletion templates/corosync.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,11 @@ quorum {
provider: corosync_votequorum
<% if @votequorum_expected_votes -%>
expected_votes: <%= @votequorum_expected_votes %>
<%-# .to_i is needed for Puppet 3 -%>
<% if @votequorum_expected_votes.to_i == 2 -%>
two_node: 1
<% end -%>
<% if [@quorum_members].flatten.count == 2 -%>
<% elsif [@quorum_members].flatten.count == 2 -%>
two_node: 1
<% end -%>
}
Expand Down

0 comments on commit 24a098f

Please sign in to comment.