Skip to content

Commit

Permalink
feat: include name in nodelist
Browse files Browse the repository at this point in the history
When the member list is names, not IP addresses, and the member name
array is empty use the former to populate the name: in the nodelist.

This addresses a parsing issue in `pcs cluster config` described in the
redhat article below. It also ensures other commands that depend on the
config file work as expected.

https://access.redhat.com/solutions/6992919
  • Loading branch information
pdemonaco committed Sep 26, 2023
1 parent f4c16c5 commit 2277369
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@
command => $quorum_setup_cmd,
path => $exec_path,
onlyif => [
'test 0 -ne $(pcs quorum config | grep "host:" >/dev/null 2>&1; echo $?)',
"test 0 -ne $(pcs quorum config | grep 'host: ${quorum_device_host}' >/dev/null 2>&1; echo $?)",
],
require => Exec['authorize_qdevice'],
before => File['/etc/corosync/corosync.conf'],
Expand Down
20 changes: 19 additions & 1 deletion spec/classes/corosync_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@
}
)
end

auth_command = if corosync_stack(os_facts)[:provider] == 'pcs'
if Gem::Version.new(corosync_stack(os_facts)[:pcs_version]) < Gem::Version.new('0.10.0')
'cluster auth'
Expand Down Expand Up @@ -1043,7 +1044,7 @@
command: 'pcs quorum device add model net host=quorum1.test.org algorithm=ffsplit',
path: '/sbin:/bin:/usr/sbin:/usr/bin',
onlyif: [
'test 0 -ne $(pcs quorum config | grep "host:" >/dev/null 2>&1; echo $?)'
"test 0 -ne $(pcs quorum config | grep 'host: quorum1.test.org' >/dev/null 2>&1; echo $?)"
],
require: 'Exec[authorize_qdevice]'
)
Expand Down Expand Up @@ -1083,6 +1084,23 @@
)
end
# else - to implement

it 'contains the quorum configuration' do
is_expected.to contain_file('/etc/corosync/corosync.conf').with_content(
%r!nodelist\s{\n
\s+node\s{\n
\s+ring0_addr:\snode1[.]test[.]org\n
\s+nodeid:\s1\n
\s+name:\snode1[.]test[.]org\n
\s+}\n
\s+node\s{\n
\s+ring0_addr:\snode2[.]test[.]org\n
\s+nodeid:\s2\n
\s+name:\snode2[.]test[.]org\n
\s+}\n
}!xm
)
end
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions templates/corosync.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ nodelist {
<% end -%>
<% if not @quorum_members_names.nil? -%>
name: <%= [@quorum_members_names].flatten[i] %>
<% elsif @quorum_members[i] !~ %r{\A([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){3}\z} -%>
name: <%= [@quorum_members].flatten[i] %>
<% end -%>
}
<% end -%>
Expand Down

0 comments on commit 2277369

Please sign in to comment.