Skip to content

Commit

Permalink
Merge 503a96f into a062493
Browse files Browse the repository at this point in the history
  • Loading branch information
timdeluxe committed Jul 10, 2020
2 parents a062493 + 503a96f commit 0285ec6
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 27 deletions.
23 changes: 22 additions & 1 deletion lib/puppet/provider/cs_location/crm.rb
Expand Up @@ -17,8 +17,29 @@
# Decided to just go with relative.
commands crm: 'crm'

# Path to the pacemakerd binary to check version for resource_discovery feature
# Decided to just go with relative.
commands pacemakerd: 'pacemakerd'

mk_resource_methods

# we need to check if we run at least pacemakerd version 1.1.13 before enabling feature discovery
# see http://blog.clusterlabs.org/blog/2014/feature-spotlight-controllable-resource-discovery
begin
pacemakerd_version_string = pacemakerd('--version')
if pacemakerd_version_string
pacemakerd_version = pacemakerd_version_string.scan(%r{\d+\.\d+\.\d+}).first
if pacemakerd_version
if Puppet::Util::Package.versioncmp(pacemakerd_version, '1.1.13') >= 0
has_feature :discovery
end
end
end
rescue Puppet::MissingCommand
# on fresh systems pacemaker is not yet installed when pacemakerd command is executed, so we do just nothing, when the executable is missing
debug('pacemakerd binary not installed. Version is not checked to find out, if discovery feature for cs_location can be used or not, so discovery feature is not set.')
end

def self.instances
block_until_ready

Expand Down Expand Up @@ -81,7 +102,7 @@ def flush
updated = "location #{@property_hash[:name]} #{@property_hash[:primitive]}"

if feature?(:discovery)
updated << " resource-discovery=#{@property_hash[:resource_discovery]}"
updated << " resource-discovery=#{@property_hash[:resource_discovery]}" unless @property_hash[:resource_discovery].nil?
end

unless @property_hash[:node_name].nil?
Expand Down
8 changes: 6 additions & 2 deletions lib/puppet/provider/cs_order/crm.rb
Expand Up @@ -93,9 +93,13 @@ def flush
return if @property_hash.empty?

updated = 'order '
updated << "#{@property_hash[:name]} #{@property_hash[:score]}: "
updated << "#{@property_hash[:name]} "
if @property_hash[:score]
updated << "#{@property_hash[:score]}: " unless @property_hash[:score].nil?
elsif feature? :kindness
updated << "#{@property_hash[:kind]}: " unless @property_hash[:kind].nil?
end
updated << "#{@property_hash[:first]} #{@property_hash[:second]} symmetrical=#{@property_hash[:symmetrical]}"
updated << " kind=#{@property_hash[:kind]}" if feature? :kindness
debug("Loading update: #{updated}")
Tempfile.open('puppet_crm_update') do |tmpfile|
tmpfile.write(updated)
Expand Down
8 changes: 0 additions & 8 deletions lib/puppet/provider/cs_order/pcs.rb
Expand Up @@ -47,11 +47,6 @@ def self.instances
else
items['then']
end
score = if items['score']
items['score']
else
'INFINITY'
end
kind = if items['kind']
items['kind']
else
Expand All @@ -70,7 +65,6 @@ def self.instances
ensure: :present,
first: first,
second: second,
score: score,
kind: kind,
symmetrical: symmetrical,
provider: name,
Expand All @@ -90,7 +84,6 @@ def create
ensure: :present,
first: @resource[:first],
second: @resource[:second],
score: @resource[:score],
kind: @resource[:kind],
symmetrical: @resource[:symmetrical],
new: true
Expand Down Expand Up @@ -126,7 +119,6 @@ def flush
items = @property_hash[:second].split(':')
cmd << items[1]
cmd << items[0]
cmd << @property_hash[:score]
cmd << "kind=#{@property_hash[:kind]}"
cmd << "id=#{@property_hash[:name]}"
cmd << "symmetrical=#{@property_hash[:symmetrical]}"
Expand Down
6 changes: 3 additions & 3 deletions lib/puppet/type/cs_order.rb
Expand Up @@ -59,9 +59,9 @@
of multiple order groups and so there is a way to control which
primitives get priority when forcing the order of state changes on
other primitives. This value can be an integer but is often defined
as the string INFINITY."

defaultto 'INFINITY'
as the string INFINITY.
When using pcs as provider this value is not used. It should be preferred
to use parameter kind in general."
end

newproperty(:kind, required_features: :kindness) do
Expand Down
17 changes: 4 additions & 13 deletions spec/acceptance/cs_location_spec.rb
Expand Up @@ -98,19 +98,10 @@ class { 'corosync':
end
end

if fact('osfamily') == 'RedHat'
it 'creates a location with resource-discovery=exclusive on EL-based systems' do
shell('cibadmin --query | grep duncan_vip_there') do |r|
expect(r.stdout).to match(%r{resource-discovery="exclusive"})
end
end
end

if fact('osfamily') != 'RedHat'
it 'creates a location without resource-discovery=exclusive on non-RH systems' do
shell('cibadmin --query | grep duncan_vip_there') do |r|
expect(r.stdout).not_to match(%r{resource-discovery="exclusive"})
end
# this requires pacemaker >= 1.1.13. All tested distributions have higher versions than 1.1.13
it 'creates a location with resource-discovery=exclusive' do
shell('cibadmin --query | grep duncan_vip_there') do |r|
expect(r.stdout).to match(%r{resource-discovery="exclusive"})
end
end

Expand Down
6 changes: 6 additions & 0 deletions spec/spec_helper_acceptance.rb
Expand Up @@ -15,6 +15,12 @@
on host, 'mkdir /etc/systemd/system/corosync.service.d'
on host, 'echo -e "[Service]\nType=simple" > /etc/systemd/system/corosync.service.d/10-type-simple.conf'
end
# Issue 455: On Centos-based there are recurring problems with the pacemaker systemd service
# refusing to stop its crmd subprocess leading to test timeouts. Force a fast SigKill here.
if host[:hypervisor] =~ %r{docker} && fact_on(host, 'os.family') == 'RedHat' && fact_on(host, 'os.release.major') == '7'
on host, 'mkdir /etc/systemd/system/pacemaker.service.d'
on host, 'echo -e "[Service]\nSendSIGKILL=yes\nTimeoutStopSec=60s" > /etc/systemd/system/pacemaker.service.d/10-timeout.conf'
end
end

def cleanup_cs_resources
Expand Down

0 comments on commit 0285ec6

Please sign in to comment.