From 6ecabc13d978a3c85a878ca5f44ccd6eec7cbdb2 Mon Sep 17 00:00:00 2001 From: Tim Eilers Date: Thu, 20 Sep 2018 14:20:58 +0200 Subject: [PATCH 01/14] Fixing setting of resource_discovery parameter. The crm provider for cs_location did never set that. A version check ensures that parameter is only set when running pacemakerd >= 1.1.13 Fixes voxpupuli/puppet-corosync#447 --- lib/puppet/provider/cs_location/crm.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/puppet/provider/cs_location/crm.rb b/lib/puppet/provider/cs_location/crm.rb index 4e68ad3b..0981a500 100644 --- a/lib/puppet/provider/cs_location/crm.rb +++ b/lib/puppet/provider/cs_location/crm.rb @@ -16,9 +16,21 @@ # Path to the crm binary for interacting with the cluster configuration. # 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 + pacemakerd_version_string = pacemakerd('--version') + pacemakerd_version = pacemakerd_version_string.scan(%r{\d+\.\d+\.\d+}).first unless pacemakerd_version_string.nil? + if Puppet::Util::Package.versioncmp(pacemakerd_version,'1.1.13') >= 0 + has_feature :discovery + end + def self.instances block_until_ready From 6e090a0fd8ef872e83af463fea576354d3f9232d Mon Sep 17 00:00:00 2001 From: Tim Eilers Date: Fri, 12 Oct 2018 15:33:51 +0200 Subject: [PATCH 02/14] Command for the fix was defined in wrong way. Corrected it. Still fixes voxpupuli/puppet-corosync#447 --- lib/puppet/provider/cs_location/crm.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/provider/cs_location/crm.rb b/lib/puppet/provider/cs_location/crm.rb index 0981a500..416af932 100644 --- a/lib/puppet/provider/cs_location/crm.rb +++ b/lib/puppet/provider/cs_location/crm.rb @@ -19,7 +19,7 @@ # Path to the pacemakerd binary to check version for resource_discovery feature # Decided to just go with relative. - commands pacemakerd: 'pacemakerd' + commands :pacemakerd => 'pacemakerd' mk_resource_methods From 354b2763b010eacc0becc8c0426144b986dc60c3 Mon Sep 17 00:00:00 2001 From: Tim Eilers Date: Tue, 16 Oct 2018 11:25:24 +0200 Subject: [PATCH 03/14] Fixing command back to correct ruby 1.9 syntax (my fault). Adding rescue to prevent issues when command is not yet found on fresh systems, where pacemaker is not yet installed. Still fixes voxpupuli/puppet-corosync#447 --- lib/puppet/provider/cs_location/crm.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/puppet/provider/cs_location/crm.rb b/lib/puppet/provider/cs_location/crm.rb index 416af932..b706a54a 100644 --- a/lib/puppet/provider/cs_location/crm.rb +++ b/lib/puppet/provider/cs_location/crm.rb @@ -19,16 +19,20 @@ # Path to the pacemakerd binary to check version for resource_discovery feature # Decided to just go with relative. - commands :pacemakerd => 'pacemakerd' + 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 - pacemakerd_version_string = pacemakerd('--version') - pacemakerd_version = pacemakerd_version_string.scan(%r{\d+\.\d+\.\d+}).first unless pacemakerd_version_string.nil? - if Puppet::Util::Package.versioncmp(pacemakerd_version,'1.1.13') >= 0 - has_feature :discovery + begin + pacemakerd_version_string = pacemakerd('--version') + pacemakerd_version = pacemakerd_version_string.scan(%r{\d+\.\d+\.\d+}).first unless pacemakerd_version_string.nil? + if Puppet::Util::Package.versioncmp(pacemakerd_version,'1.1.13') >= 0 + has_feature :discovery + end + rescue Puppet::MissingCommand + # on fresh systems pacemaker is not yet installed when facts are gathered, so we do just nothing, when the executable is missing end def self.instances From 09c8aacccf2f506d95819e290f8769f93915d866 Mon Sep 17 00:00:00 2001 From: Tim Eilers Date: Tue, 16 Oct 2018 13:00:09 +0200 Subject: [PATCH 04/14] Improving code for case when version is nil Still fixes voxpupuli/puppet-corosync#447 --- lib/puppet/provider/cs_location/crm.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/puppet/provider/cs_location/crm.rb b/lib/puppet/provider/cs_location/crm.rb index b706a54a..f23a3233 100644 --- a/lib/puppet/provider/cs_location/crm.rb +++ b/lib/puppet/provider/cs_location/crm.rb @@ -25,11 +25,16 @@ # 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') - pacemakerd_version = pacemakerd_version_string.scan(%r{\d+\.\d+\.\d+}).first unless pacemakerd_version_string.nil? - if Puppet::Util::Package.versioncmp(pacemakerd_version,'1.1.13') >= 0 - has_feature :discovery + if pacemakerd_version_string != nil + pacemakerd_version = pacemakerd_version_string.scan(%r{\d+\.\d+\.\d+}).first unless pacemakerd_version_string.nil? + if pacemakerd_version != nil + 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 facts are gathered, so we do just nothing, when the executable is missing From aa87e8964200d33ea7335283c59368a9345663ab Mon Sep 17 00:00:00 2001 From: Tim Eilers Date: Wed, 8 May 2019 10:00:08 +0200 Subject: [PATCH 05/14] Introducing custom fact for pacemakerd version and changing providers and acceptance tests according to it. Still trying to fix #447 --- lib/facter/pacemakerd_version.rb | 14 ++++++++++++++ lib/puppet/provider/cs_location/crm.rb | 19 +++---------------- spec/acceptance/cs_location_spec.rb | 8 ++++---- 3 files changed, 21 insertions(+), 20 deletions(-) create mode 100644 lib/facter/pacemakerd_version.rb diff --git a/lib/facter/pacemakerd_version.rb b/lib/facter/pacemakerd_version.rb new file mode 100644 index 00000000..16a57ac3 --- /dev/null +++ b/lib/facter/pacemakerd_version.rb @@ -0,0 +1,14 @@ +Facter.add(:pacemakerd_version) do + setcode do + pacemakerd_version_string = nil + + pacemakerd_version_string = Facter::Util::Resolution.exec('pacemakerd --version 2>&1') + + unless pacemakerd_version_string.nil? + match = %r{^Pacemaker (\d+.\d+(.\d+)?)}.match(pacemakerd_version_string) + unless match.nil? + match[1] + end + end + end +end \ No newline at end of file diff --git a/lib/puppet/provider/cs_location/crm.rb b/lib/puppet/provider/cs_location/crm.rb index ba0511bb..c07c5b72 100644 --- a/lib/puppet/provider/cs_location/crm.rb +++ b/lib/puppet/provider/cs_location/crm.rb @@ -16,28 +16,15 @@ # Path to the crm binary for interacting with the cluster configuration. # 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 != nil - pacemakerd_version = pacemakerd_version_string.scan(%r{\d+\.\d+\.\d+}).first unless pacemakerd_version_string.nil? - if pacemakerd_version != nil - if Puppet::Util::Package.versioncmp(pacemakerd_version,'1.1.13') >= 0 - has_feature :discovery - end - end + if !Facter.value('pacemakerd_version').nil? + if Puppet::Util::Package.versioncmp(Facter.value('pacemakerd_version'), '1.1.13') >= 0 + has_feature :discovery end - rescue Puppet::MissingCommand - # on fresh systems pacemaker is not yet installed when facts are gathered, so we do just nothing, when the executable is missing end def self.instances diff --git a/spec/acceptance/cs_location_spec.rb b/spec/acceptance/cs_location_spec.rb index c9c766bc..0d609228 100755 --- a/spec/acceptance/cs_location_spec.rb +++ b/spec/acceptance/cs_location_spec.rb @@ -98,16 +98,16 @@ class { 'corosync': end end - if fact('osfamily') == 'RedHat' - it 'creates a location with resource-discovery=exclusive on EL-based systems' do + if Gem::Version.new(fact('pacemakerd_version')) >= Gem::Version.new('1.1.13') + it 'creates a location with resource-discovery=exclusive on pacemakerd version >= 1.1.13' 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 + if Gem::Version.new(fact('pacemakerd_version')) < Gem::Version.new('1.1.13') + it 'creates a location without resource-discovery=exclusive on pacemakerd version < 1.1.13' do shell('cibadmin --query | grep duncan_vip_there') do |r| expect(r.stdout).not_to match(%r{resource-discovery="exclusive"}) end From 5e8b2c1a3b1b533070db3585434733d06045db2c Mon Sep 17 00:00:00 2001 From: Tim Eilers Date: Wed, 8 May 2019 10:11:55 +0200 Subject: [PATCH 06/14] Fixing rubocop issues Still trying to fix #447 --- lib/facter/pacemakerd_version.rb | 7 ++----- lib/puppet/provider/cs_location/crm.rb | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/facter/pacemakerd_version.rb b/lib/facter/pacemakerd_version.rb index 16a57ac3..53f1e04f 100644 --- a/lib/facter/pacemakerd_version.rb +++ b/lib/facter/pacemakerd_version.rb @@ -1,14 +1,11 @@ Facter.add(:pacemakerd_version) do setcode do - pacemakerd_version_string = nil pacemakerd_version_string = Facter::Util::Resolution.exec('pacemakerd --version 2>&1') unless pacemakerd_version_string.nil? match = %r{^Pacemaker (\d+.\d+(.\d+)?)}.match(pacemakerd_version_string) - unless match.nil? - match[1] - end + match[1] unless match.nil? end end -end \ No newline at end of file +end diff --git a/lib/puppet/provider/cs_location/crm.rb b/lib/puppet/provider/cs_location/crm.rb index c07c5b72..24c57879 100644 --- a/lib/puppet/provider/cs_location/crm.rb +++ b/lib/puppet/provider/cs_location/crm.rb @@ -21,7 +21,7 @@ # 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 - if !Facter.value('pacemakerd_version').nil? + unless Facter.value('pacemakerd_version').nil? if Puppet::Util::Package.versioncmp(Facter.value('pacemakerd_version'), '1.1.13') >= 0 has_feature :discovery end From 7af4a0eb363889d36cb4843e6b094570c6af7905 Mon Sep 17 00:00:00 2001 From: Tim Eilers Date: Wed, 8 May 2019 10:19:16 +0200 Subject: [PATCH 07/14] Fixing rubocop issues Still trying to fix #447 --- lib/facter/pacemakerd_version.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/facter/pacemakerd_version.rb b/lib/facter/pacemakerd_version.rb index 53f1e04f..c930fb57 100644 --- a/lib/facter/pacemakerd_version.rb +++ b/lib/facter/pacemakerd_version.rb @@ -1,6 +1,5 @@ Facter.add(:pacemakerd_version) do setcode do - pacemakerd_version_string = Facter::Util::Resolution.exec('pacemakerd --version 2>&1') unless pacemakerd_version_string.nil? From 9c3b04ce54c1023b1ca06fa800b8e88d3a6cabc8 Mon Sep 17 00:00:00 2001 From: Tim Eilers Date: Thu, 9 Jul 2020 16:45:54 +0200 Subject: [PATCH 08/14] Removing custom fact and adding direct command execution back into crm provider. Updating acceptance tests to work correctly with resource-discovery. Still trying to fix #447 --- lib/facter/pacemakerd_version.rb | 10 ---------- lib/puppet/provider/cs_location/crm.rb | 20 +++++++++++++++++--- spec/acceptance/cs_location_spec.rb | 17 ++++------------- 3 files changed, 21 insertions(+), 26 deletions(-) delete mode 100644 lib/facter/pacemakerd_version.rb diff --git a/lib/facter/pacemakerd_version.rb b/lib/facter/pacemakerd_version.rb deleted file mode 100644 index c930fb57..00000000 --- a/lib/facter/pacemakerd_version.rb +++ /dev/null @@ -1,10 +0,0 @@ -Facter.add(:pacemakerd_version) do - setcode do - pacemakerd_version_string = Facter::Util::Resolution.exec('pacemakerd --version 2>&1') - - unless pacemakerd_version_string.nil? - match = %r{^Pacemaker (\d+.\d+(.\d+)?)}.match(pacemakerd_version_string) - match[1] unless match.nil? - end - end -end diff --git a/lib/puppet/provider/cs_location/crm.rb b/lib/puppet/provider/cs_location/crm.rb index 24c57879..4e2f3847 100644 --- a/lib/puppet/provider/cs_location/crm.rb +++ b/lib/puppet/provider/cs_location/crm.rb @@ -17,15 +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 + # rubocop:disable Lint/HandleExceptions # 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 - unless Facter.value('pacemakerd_version').nil? - if Puppet::Util::Package.versioncmp(Facter.value('pacemakerd_version'), '1.1.13') >= 0 - has_feature :discovery + begin + pacemakerd_version_string = pacemakerd('--version') + if pacemakerd_version_string + pacemakerd_version = pacemakerd_version_string.scan(%r{\d+\.\d+\.\d+}).first unless pacemakerd_version_string.nil? + 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 facts are gathered, so we do just nothing, when the executable is missing end + # rubocop:enable Lint/HandleExceptions def self.instances block_until_ready diff --git a/spec/acceptance/cs_location_spec.rb b/spec/acceptance/cs_location_spec.rb index 0d609228..d476b5a0 100755 --- a/spec/acceptance/cs_location_spec.rb +++ b/spec/acceptance/cs_location_spec.rb @@ -98,19 +98,10 @@ class { 'corosync': end end - if Gem::Version.new(fact('pacemakerd_version')) >= Gem::Version.new('1.1.13') - it 'creates a location with resource-discovery=exclusive on pacemakerd version >= 1.1.13' do - shell('cibadmin --query | grep duncan_vip_there') do |r| - expect(r.stdout).to match(%r{resource-discovery="exclusive"}) - end - end - end - - if Gem::Version.new(fact('pacemakerd_version')) < Gem::Version.new('1.1.13') - it 'creates a location without resource-discovery=exclusive on pacemakerd version < 1.1.13' 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 From 4621d8fd3883a7f3d1b7ede583adc505c974d8c4 Mon Sep 17 00:00:00 2001 From: Tim Eilers Date: Fri, 10 Jul 2020 11:22:57 +0200 Subject: [PATCH 09/14] Updating pacemaker version check for discovery feature after pull request hints. Fixing setting of discovery parameter. Still trying to fix #447 --- lib/puppet/provider/cs_location/crm.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/puppet/provider/cs_location/crm.rb b/lib/puppet/provider/cs_location/crm.rb index 4e2f3847..3ac34966 100644 --- a/lib/puppet/provider/cs_location/crm.rb +++ b/lib/puppet/provider/cs_location/crm.rb @@ -23,13 +23,12 @@ mk_resource_methods - # rubocop:disable Lint/HandleExceptions # 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 unless pacemakerd_version_string.nil? + 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 @@ -37,9 +36,9 @@ end end rescue Puppet::MissingCommand - # on fresh systems pacemaker is not yet installed when facts are gathered, so we do just nothing, when the executable is missing + # 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 - # rubocop:enable Lint/HandleExceptions def self.instances block_until_ready @@ -103,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? From 9ee500c9a571c3150269262076c2ae2fc71948c8 Mon Sep 17 00:00:00 2001 From: Tim Eilers Date: Fri, 10 Jul 2020 11:25:04 +0200 Subject: [PATCH 10/14] Fixing score/kind setting on cs_order --- lib/puppet/provider/cs_order/crm.rb | 10 ++++++++-- lib/puppet/provider/cs_order/pcs.rb | 8 -------- lib/puppet/type/cs_order.rb | 6 +++--- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/puppet/provider/cs_order/crm.rb b/lib/puppet/provider/cs_order/crm.rb index 716142f5..88586348 100644 --- a/lib/puppet/provider/cs_order/crm.rb +++ b/lib/puppet/provider/cs_order/crm.rb @@ -93,9 +93,15 @@ 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? + else + if feature? :kindness + updated << "#{@property_hash[:kind]}: " unless @property_hash[:kind].nil? + end + 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) diff --git a/lib/puppet/provider/cs_order/pcs.rb b/lib/puppet/provider/cs_order/pcs.rb index 788b2369..c26225a2 100644 --- a/lib/puppet/provider/cs_order/pcs.rb +++ b/lib/puppet/provider/cs_order/pcs.rb @@ -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 @@ -70,7 +65,6 @@ def self.instances ensure: :present, first: first, second: second, - score: score, kind: kind, symmetrical: symmetrical, provider: name, @@ -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 @@ -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]}" diff --git a/lib/puppet/type/cs_order.rb b/lib/puppet/type/cs_order.rb index 19291eeb..2fb795cd 100644 --- a/lib/puppet/type/cs_order.rb +++ b/lib/puppet/type/cs_order.rb @@ -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 From 26b81c0a562c96dca35f74327827dde9e70d4872 Mon Sep 17 00:00:00 2001 From: Tim Eilers Date: Fri, 10 Jul 2020 11:26:16 +0200 Subject: [PATCH 11/14] Implementing workaround for hanging service restarts on RedHat-based OS as proposed in #455 to fix beaker tests --- spec/spec_helper_acceptance.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index a5cda856..13d06829 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -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 From 503a96f8bd133671ef72fb7642dbc90fc23a3ee6 Mon Sep 17 00:00:00 2001 From: Tim Eilers Date: Fri, 10 Jul 2020 11:31:34 +0200 Subject: [PATCH 12/14] Fixing code style highlighted by rubocop on cs_order crm provider --- lib/puppet/provider/cs_order/crm.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/puppet/provider/cs_order/crm.rb b/lib/puppet/provider/cs_order/crm.rb index 88586348..d1c3ef19 100644 --- a/lib/puppet/provider/cs_order/crm.rb +++ b/lib/puppet/provider/cs_order/crm.rb @@ -96,10 +96,8 @@ def flush updated << "#{@property_hash[:name]} " if @property_hash[:score] updated << "#{@property_hash[:score]}: " unless @property_hash[:score].nil? - else - if feature? :kindness - updated << "#{@property_hash[:kind]}: " unless @property_hash[:kind].nil? - end + elsif feature? :kindness + updated << "#{@property_hash[:kind]}: " unless @property_hash[:kind].nil? end updated << "#{@property_hash[:first]} #{@property_hash[:second]} symmetrical=#{@property_hash[:symmetrical]}" debug("Loading update: #{updated}") From a173a127dd7a1e7eb4313093c7a3cc85d71a87c8 Mon Sep 17 00:00:00 2001 From: Tim Eilers Date: Fri, 10 Jul 2020 12:41:22 +0200 Subject: [PATCH 13/14] Fixing kind handling on cs_order crm provider. Fixing wording on cs_order score parameter. --- lib/puppet/provider/cs_order/crm.rb | 11 +++++++++-- lib/puppet/type/cs_order.rb | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/puppet/provider/cs_order/crm.rb b/lib/puppet/provider/cs_order/crm.rb index d1c3ef19..f2679117 100644 --- a/lib/puppet/provider/cs_order/crm.rb +++ b/lib/puppet/provider/cs_order/crm.rb @@ -42,6 +42,12 @@ def self.instances items['then'] end + kind = if items['kind'] + items['kind'] + else + 'Mandatory' + end + symmetrical = if items['symmetrical'] (items['symmetrical'] == 'true') else @@ -55,6 +61,7 @@ def self.instances first: first, second: second, score: items['score'], + kind: kind, symmetrical: symmetrical, provider: name } @@ -95,9 +102,9 @@ def flush updated = 'order ' updated << "#{@property_hash[:name]} " if @property_hash[:score] - updated << "#{@property_hash[:score]}: " unless @property_hash[:score].nil? + updated << "#{@property_hash[:score]}: " elsif feature? :kindness - updated << "#{@property_hash[:kind]}: " unless @property_hash[:kind].nil? + updated << "#{@property_hash[:kind]}: " end updated << "#{@property_hash[:first]} #{@property_hash[:second]} symmetrical=#{@property_hash[:symmetrical]}" debug("Loading update: #{updated}") diff --git a/lib/puppet/type/cs_order.rb b/lib/puppet/type/cs_order.rb index 2fb795cd..f0b84a63 100644 --- a/lib/puppet/type/cs_order.rb +++ b/lib/puppet/type/cs_order.rb @@ -60,8 +60,8 @@ 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. - When using pcs as provider this value is not used. It should be preferred - to use parameter kind in general." + When using pcs as provider this value is not used. + It is generally preferred to use the `kind` parameter." end newproperty(:kind, required_features: :kindness) do From 8e15000c625bbcf0eeca90d3fc206f3c306e91fe Mon Sep 17 00:00:00 2001 From: Tim Eilers Date: Fri, 10 Jul 2020 13:18:40 +0200 Subject: [PATCH 14/14] Fixing cs_order_crm unit tests after fixing kind stuff in cs_order provider. --- spec/unit/puppet/provider/cs_order_crm_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/unit/puppet/provider/cs_order_crm_spec.rb b/spec/unit/puppet/provider/cs_order_crm_spec.rb index 34f93c06..28e2e4a3 100644 --- a/spec/unit/puppet/provider/cs_order_crm_spec.rb +++ b/spec/unit/puppet/provider/cs_order_crm_spec.rb @@ -57,8 +57,8 @@ expect(instance.second).to eq('nul-interface-2:start') end - it 'has kind equal to absent' do - expect(instance.kind).to eq(:absent) + it 'has kind equal to Mandatory' do + expect(instance.kind).to eq('Mandatory') end it 'has symmetrical set to true' do @@ -79,8 +79,8 @@ expect(instance.second).to eq('nul-interface-2b:start') end - it 'has kind equal to absent' do - expect(instance.kind).to eq(:absent) + it 'has kind equal to Optional' do + expect(instance.kind).to eq('Optional') end it 'has symmetrical set to false' do