Browse Source

Make pcs resource config/show work depending on the installed pcs version

When we added Id8807a644a6d53f89f99b9db988cbbca99abb7ab we were under
the impression that train and centos-7 was not a thing. Since centos-7
pcs does not have the pcs resource config it is likely we will fail to
recognize existing resources.

This can be removed once we stop supporting centos 7, but for now let's
support both transparently.

Tested on both centos-7 env where it was failing and on a centos-8 train
deployment.

Closes-Bug: #1915519

Change-Id: Ie07b37581e844b64063e5e501f09edf4c8ef24e3
changes/00/777000/2 1.2.0
Michele Baldessari 5 months ago
parent
commit
6e272bf9ec
  1. 2
      lib/puppet/provider/pcmk_bundle/default.rb
  2. 13
      lib/puppet/provider/pcmk_common.rb
  3. 2
      lib/puppet/provider/pcmk_remote/default.rb
  4. 2
      lib/puppet/provider/pcmk_resource/default.rb
  5. 2
      lib/puppet/provider/pcmk_stonith/default.rb

2
lib/puppet/provider/pcmk_bundle/default.rb

@ -178,7 +178,7 @@ Puppet::Type.type(:pcmk_bundle).provide(:default) do
end
def resource_exists?
cmd = 'resource config ' + @resource[:name] + ' > /dev/null 2>&1'
cmd = 'resource ' + pcs_config_or_show() + ' ' + @resource[:name] + ' > /dev/null 2>&1'
ret = pcs('show', @resource[:name], cmd, @resource[:tries],
@resource[:try_sleep], @resource[:verify_on_create], @resource[:post_success_sleep])
if ret == false then

13
lib/puppet/provider/pcmk_common.rb

@ -37,6 +37,17 @@ def pcs_cli_version()
return pcs_cli_version
end
# returns 'show' or 'config' depending on the pcs version
# In case pcs returns '' we choose the more recent 'config' default
# (Although in that case it is likely it will fail differently anyways)
def pcs_config_or_show()
if Puppet::Util::Package.versioncmp(pcs_cli_version(), '0.10.0') < 0
return 'show'
else
return 'config'
end
end
def crm_node_l()
begin
nodes = `#{CRMNODE_BIN} -l`
@ -191,7 +202,7 @@ def pcs_create_with_verify(name, resource_name, cmd, tries=1, try_sleep=0)
pcs_out = `#{PCS_BIN} #{cmd} 2>&1`
if $?.exitstatus == 0
sleep try_sleep
cmd_show = "#{PCS_BIN} resource config " + resource_name
cmd_show = "#{PCS_BIN} resource " + pcs_config_or_show() + " " + resource_name
Puppet.debug("Verifying with: "+cmd_show)
`#{cmd_show}`
if $?.exitstatus == 0

2
lib/puppet/provider/pcmk_remote/default.rb

@ -81,7 +81,7 @@ Puppet::Type.type(:pcmk_remote).provide(:default) do
end
def resource_exists?
cmd = 'resource config ' + @resource[:name] + ' > /dev/null 2>&1'
cmd = 'resource ' + pcs_config_or_show() + ' ' + @resource[:name] + ' > /dev/null 2>&1'
ret = pcs('show', @resource[:name], cmd, @resource[:tries],
@resource[:try_sleep], false, @resource[:post_success_sleep])
if ret == false then

2
lib/puppet/provider/pcmk_resource/default.rb

@ -159,7 +159,7 @@ Puppet::Type.type(:pcmk_resource).provide(:default) do
end
def resource_exists?
cmd = 'resource config ' + @resource[:name] + ' > /dev/null 2>&1'
cmd = 'resource ' + pcs_config_or_show() + ' ' + @resource[:name] + ' > /dev/null 2>&1'
ret = pcs('show', @resource[:name], cmd, @resource[:tries],
@resource[:try_sleep], @resource[:verify_on_create], @resource[:post_success_sleep])
if ret == false then

2
lib/puppet/provider/pcmk_stonith/default.rb

@ -103,7 +103,7 @@ Puppet::Type.type(:pcmk_stonith).provide(:default) do
end
def stonith_resource_exists?
cmd = 'stonith config ' + @resource[:name] + ' > /dev/null 2>&1'
cmd = 'stonith ' + pcs_config_or_show() + ' ' + @resource[:name] + ' > /dev/null 2>&1'
ret = pcs('show', @resource[:name], cmd, @resource[:tries],
@resource[:try_sleep], @resource[:verify_on_create], @resource[:post_success_sleep])
if ret == false then

Loading…
Cancel
Save