Merge "Do not create stonith location constraint when there is a single node"

This commit is contained in:
Zuul 2020-07-30 14:03:59 +00:00 committed by Gerrit Code Review
commit 115c346dc1
2 changed files with 12 additions and 1 deletions

View File

@ -20,6 +20,7 @@ end
PCS_BIN = "#{prefix_path}pcs" unless defined? PCS_BIN PCS_BIN = "#{prefix_path}pcs" unless defined? PCS_BIN
CRMDIFF_BIN = "#{prefix_path}crm_diff" unless defined? CRMDIFF_BIN CRMDIFF_BIN = "#{prefix_path}crm_diff" unless defined? CRMDIFF_BIN
CRMNODE_BIN = "#{prefix_path}crm_node" unless defined? CRMNODE_BIN
CRMSIMULATE_BIN = "#{prefix_path}crm_simulate" unless defined? CRMSIMULATE_BIN CRMSIMULATE_BIN = "#{prefix_path}crm_simulate" unless defined? CRMSIMULATE_BIN
CRMRESOURCE_BIN = "#{prefix_path}crm_resource" unless defined? CRMRESOURCE_BIN CRMRESOURCE_BIN = "#{prefix_path}crm_resource" unless defined? CRMRESOURCE_BIN
TIMEOUT_BIN = "#{prefix_path}timeout" unless defined? TIMEOUT_BIN TIMEOUT_BIN = "#{prefix_path}timeout" unless defined? TIMEOUT_BIN
@ -36,6 +37,15 @@ def pcs_cli_version()
return pcs_cli_version return pcs_cli_version
end end
def crm_node_l()
begin
nodes = `#{CRMNODE_BIN} -l`
rescue
nodes = ''
end
return nodes
end
# Ruby 2.5 has dropped Dir::Tmpname.make_tmpname # Ruby 2.5 has dropped Dir::Tmpname.make_tmpname
# https://github.com/ruby/ruby/commit/25d56ea7b7b52dc81af30c92a9a0e2d2dab6ff27 # https://github.com/ruby/ruby/commit/25d56ea7b7b52dc81af30c92a9a0e2d2dab6ff27

View File

@ -131,7 +131,8 @@ Puppet::Type.type(:pcmk_stonith).provide(:default) do
def stonith_location_rule_create() def stonith_location_rule_create()
pcmk_host_list = @resource[:pcmk_host_list] pcmk_host_list = @resource[:pcmk_host_list]
if not_empty_string(pcmk_host_list) nodes_count = crm_node_l().lines.size
if not_empty_string(pcmk_host_list) and nodes_count > 1
location_cmd = "constraint location #{@resource[:name]} avoids #{pcmk_host_list}=10000" location_cmd = "constraint location #{@resource[:name]} avoids #{pcmk_host_list}=10000"
Puppet.debug("stonith_location_rule_create: #{location_cmd}") Puppet.debug("stonith_location_rule_create: #{location_cmd}")
pcs('create', @resource[:name], location_cmd, @resource[:tries], pcs('create', @resource[:name], location_cmd, @resource[:tries],