Browse Source

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

changes/90/744190/1
Zuul 6 days ago
committed by Gerrit Code Review
parent
commit
115c346dc1
2 changed files with 12 additions and 1 deletions
  1. +10
    -0
      lib/puppet/provider/pcmk_common.rb
  2. +2
    -1
      lib/puppet/provider/pcmk_stonith/default.rb

+ 10
- 0
lib/puppet/provider/pcmk_common.rb View File

@@ -20,6 +20,7 @@ end

PCS_BIN = "#{prefix_path}pcs" unless defined? PCS_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
CRMRESOURCE_BIN = "#{prefix_path}crm_resource" unless defined? CRMRESOURCE_BIN
TIMEOUT_BIN = "#{prefix_path}timeout" unless defined? TIMEOUT_BIN
@@ -36,6 +37,15 @@ def pcs_cli_version()
return pcs_cli_version
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
# https://github.com/ruby/ruby/commit/25d56ea7b7b52dc81af30c92a9a0e2d2dab6ff27


+ 2
- 1
lib/puppet/provider/pcmk_stonith/default.rb View File

@@ -131,7 +131,8 @@ Puppet::Type.type(:pcmk_stonith).provide(:default) do

def stonith_location_rule_create()
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"
Puppet.debug("stonith_location_rule_create: #{location_cmd}")
pcs('create', @resource[:name], location_cmd, @resource[:tries],


Loading…
Cancel
Save