Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use chomp instead of chop #555

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-02-20 13:57:00 UTC using RuboCop version 1.50.2.
# on 2024-04-08 21:01:49 UTC using RuboCop version 1.60.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
Expand All @@ -15,6 +15,7 @@ Lint/DuplicateBranch:
- 'spec/spec_helper_corosync.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: CheckForMethodsWithNoSideEffects.
Lint/Void:
Exclude:
Expand Down Expand Up @@ -51,10 +52,24 @@ RSpec/RepeatedExampleGroupBody:
- 'spec/acceptance/corosync_class_spec.rb'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowedMethods, AllowedPatterns.
# AllowedMethods: ==, equal?, eql?
Style/ClassEqualityComparison:
Exclude:
- 'lib/puppet/provider/cs_primitive/crm.rb'
- 'lib/puppet/provider/cs_primitive/pcs.rb'

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Exclude:
- 'lib/puppet/provider/cs_group/crm.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/RedundantLineContinuation:
Exclude:
- 'spec/unit/puppet/type/cs_clone_spec.rb'
4 changes: 2 additions & 2 deletions lib/puppet/provider/cs_clone/pcs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

mk_resource_methods

defaultfor operatingsystem: %i[fedora centos redhat]
defaultfor 'os.family' => %i[redhat debian]

def change_clone_id(type, primitive, id, cib)
xpath = "/cib/configuration/resources/clone[descendant::#{type}[@id='#{primitive}']]"
Expand All @@ -28,7 +28,7 @@ def change_clone_id(type, primitive, id, cib)
return unless doc.root.attributes['id'] != id

doc.root.attributes['id'] = id
cmd = [command(:cibadmin), '--replace', '--xpath', xpath, '--xml-text', doc.to_s.chop]
cmd = [command(:cibadmin), '--replace', '--xpath', xpath, '--xml-text', doc.to_s.chomp]
self.class.run_command_in_cib(cmd, cib)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/cs_colocation/pcs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
of current primitive colocations on the system; add, delete, or adjust various
aspects.'

defaultfor operatingsystem: %i[fedora centos redhat]
defaultfor 'os.family' => %i[redhat debian]

commands pcs: 'pcs'

Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/provider/cs_commit/pcs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
abstract corosync/pacemaker vs. keepalived. This provider flushes the CIB
generated by previous commands to cluster.'

defaultfor 'os.family' => %i[redhat debian]

commands cibadmin: 'cibadmin'
# Required for block_until_ready
commands pcs: 'pcs'
Expand Down
2 changes: 0 additions & 2 deletions lib/puppet/provider/cs_group/crm.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# frozen_string_literal: true

begin
require 'puppet_x/voxpupuli/corosync/provider/crmsh'
rescue LoadError
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/cs_group/pcs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Puppet::Type.type(:cs_group).provide(:pcs, parent: PuppetX::Voxpupuli::Corosync::Provider::Pcs) do
desc 'Provider to add, delete, manipulate primitive groups.'

defaultfor operatingsystem: %i[fedora centos redhat]
defaultfor 'os.family' => %i[redhat debian]

# Path to the pcs binary for interacting with the cluster configuration.
commands pcs: '/usr/sbin/pcs'
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/cs_location/pcs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
of current primitive locations on the system; add, delete, or adjust various
aspects.'

defaultfor operatingsystem: %i[fedora centos redhat]
defaultfor 'os.family' => %i[redhat debian]
has_feature :discovery

commands pcs: 'pcs'
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/cs_order/pcs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
of current primitive start orders on the system; add, delete, or adjust various
aspects.'

defaultfor operatingsystem: %i[fedora centos redhat]
defaultfor 'os.family' => %i[redhat debian]

has_feature :kindness

Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/cs_primitive/pcs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

mk_resource_methods

defaultfor operatingsystem: %i[fedora centos redhat]
defaultfor 'os.family' => %i[redhat debian]

# given an XML element (a <primitive> from cibadmin), produce a hash suitible
# for creating a new provider instance.
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/cs_property/pcs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
abstract corosync/pacemaker vs. keepalived. This provider will check the state
of Corosync cluster configuration properties.'

defaultfor operatingsystem: %i[fedora centos redhat]
defaultfor 'os.family' => %i[redhat debian]

# Path to the pcs binary for interacting with the cluster configuration.
commands pcs: 'pcs'
Expand Down
2 changes: 1 addition & 1 deletion lib/puppet/provider/cs_rsc_defaults/pcs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
abstract corosync/pacemaker vs. keepalived. This provider will check the state
of Corosync global defaults for resource options.'

defaultfor operatingsystem: %i[fedora centos redhat]
defaultfor 'os.family' => %i[redhat debian]

# Path to the pcs binary for interacting with the cluster configuration.
commands pcs: 'pcs'
Expand Down
2 changes: 2 additions & 0 deletions lib/puppet/provider/cs_shadow/pcs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
abstract corosync/pacemaker vs. keepalived. This provider initializes a new CIB
to begin tracking cluster changes.'

defaultfor 'os.family' => %i[redhat debian]

commands cibadmin: 'cibadmin'
# Required for block_until_ready
commands pcs: 'pcs'
Expand Down
4 changes: 3 additions & 1 deletion spec/acceptance/cs_location_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true
# rubocop:disable Style/FrozenStringLiteralComment

require 'spec_helper_acceptance'

Expand Down Expand Up @@ -243,3 +243,5 @@ class { 'corosync':
end
end
end

# rubocop:enable Style/FrozenStringLiteralComment
4 changes: 3 additions & 1 deletion spec/acceptance/cs_order_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true
# rubocop:disable Style/FrozenStringLiteralComment

require 'spec_helper_acceptance'

Expand Down Expand Up @@ -173,3 +173,5 @@ class { 'corosync':
end
end
end

# rubocop:enable Style/FrozenStringLiteralComment
4 changes: 2 additions & 2 deletions spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
# On Debian-based, service state transitions (restart, stop) hang indefinitely and
# lead to test timeouts if there is a service unit of Type=notify involved.
# Use Type=simple as a workaround. See issue 455.
if host[:hypervisor] =~ %r{docker} && fact_on(host, 'os.family') == 'Debian'
if host[:hypervisor] =~ %r{(vagrant|docker)} && fact_on(host, 'os.family') == 'Debian'
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'
if host[:hypervisor] =~ %r{(vagrant|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
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/puppet/provider/cs_clone_pcs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def clone_xml(name)
Puppet::Util::Execution.expects(:execute).with(['cibadmin', '--query', '--xpath', xpath], failonfail: true, combine: true).at_least_once.returns(
Puppet::Util::Execution::ProcessOutput.new(clone_xml('apache_service-clone'), 0)
)
Puppet::Util::Execution.expects(:execute).with(['cibadmin', '--replace', '--xpath', xpath, '--xml-text', clone_xml('apache_service-newclone').chop], failonfail: true, combine: true).at_least_once.returns(
Puppet::Util::Execution.expects(:execute).with(['cibadmin', '--replace', '--xpath', xpath, '--xml-text', clone_xml('apache_service-newclone').chomp], failonfail: true, combine: true).at_least_once.returns(
Puppet::Util::Execution::ProcessOutput.new('', 0)
)
instance.change_clone_id('primitive', 'apache_service', 'apache_service-newclone', nil)
Expand Down
Loading