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

[UNTESTED] Fix remote node maintenance (bsc#983617) #187

Open
wants to merge 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def report

if maintenance_mode?
Chef::Log.info("Taking node out of Pacemaker maintenance mode")
system("crm --wait node ready")
system("crm --wait node ready #{pacemaker_node_name}")
else
# This shouldn't happen, and suggests that one of the recipes
# is interfering in a way it shouldn't.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ module CrowbarPacemaker
# A mixin for Chef::Pacemaker::Handler subclasses, and also for the
# Chef::Provider::PacemakerService LWRP.
module MaintenanceModeHelpers
def maintenance_mode?
pacemaker_node = if !node[:pacemaker].nil? && node[:pacemaker][:is_remote]
def pacemaker_node_name
if !node[:pacemaker].nil? && node[:pacemaker][:is_remote]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about just if node[:pacemaker] && node[:pacemaker][:is_remote] ?

"remote-#{node.hostname}"
else
node.hostname
end
end

def maintenance_mode?
# See https://bugzilla.suse.com/show_bug.cgi?id=870696
!! (`crm_attribute -G -N #{pacemaker_node} -n maintenance -d off -q` =~ /^on$/)
!! (`crm_attribute -G -N #{pacemaker_node_name} -n maintenance -d off -q` =~ /^on$/)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/DoubleNegation: Avoid the use of double negation (!!). (https://github.com/bbatsov/ruby-style-guide#no-bang-bang)
Style/SpaceAfterNot: Do not leave space between ! and its argument. (https://github.com/bbatsov/ruby-style-guide#no-space-bang)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here.

end

def record_maintenance_mode_before_this_chef_run
Expand Down Expand Up @@ -65,7 +68,7 @@ def set_maintenance_mode
elsif maintenance_mode?
Chef::Log.info("Something else already placed this node in Pacemaker maintenance mode")
else
execute "crm --wait node maintenance" do
execute "crm --wait node maintenance #{pacemaker_node_name}" do
action :nothing
end.run_action(:run)
set_maintenance_mode_via_this_chef_run
Expand Down
2 changes: 1 addition & 1 deletion chef/cookbooks/pacemaker/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
default[:pacemaker][:platform][:packages] =
%w(pacemaker crmsh fence-agents)
default[:pacemaker][:platform][:remote_packages] =
%w(pacemaker-remote fence-agents)
%w(pacemaker-remote pacemaker-cli crmsh fence-agents)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/WordArray: Use [] for an array of words. (https://github.com/SUSE/style-guides/blob/master/Ruby.md#stylewordarray)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I disagree with the dog here.

default[:pacemaker][:platform][:sbd_packages] =
%w(sbd)
else
Expand Down