From 931e04da792feff2ab4bf042231f59cb48213825 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 20 Mar 2017 16:03:45 +0000 Subject: [PATCH 1/2] extract calculation of pacemaker node name into reusable method We want to be able to reuse this when constructing the command for toggling maintenance mode, since when doing it for remotes, you need to specify the node name. --- .../libraries/maintenance_mode_helpers.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/chef/cookbooks/crowbar-pacemaker/libraries/maintenance_mode_helpers.rb b/chef/cookbooks/crowbar-pacemaker/libraries/maintenance_mode_helpers.rb index 599702b5..0cb93772 100644 --- a/chef/cookbooks/crowbar-pacemaker/libraries/maintenance_mode_helpers.rb +++ b/chef/cookbooks/crowbar-pacemaker/libraries/maintenance_mode_helpers.rb @@ -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] "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$/) end def record_maintenance_mode_before_this_chef_run From f35a9b3b6c166b89a9bada7a079667d4c6b2f700 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 20 Mar 2017 16:05:29 +0000 Subject: [PATCH 2/2] fix toggling maintenance mode for remote nodes (bsc#983617) We need crm and crm_attribute installed on the remote nodes, and we also need to specify the pacemaker node name when toggling the mode, as explained in https://bugzilla.suse.com/show_bug.cgi?id=983617#c14 --- .../files/default/pacemaker_maintenance_handlers.rb | 2 +- .../crowbar-pacemaker/libraries/maintenance_mode_helpers.rb | 2 +- chef/cookbooks/pacemaker/attributes/default.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/chef/cookbooks/crowbar-pacemaker/files/default/pacemaker_maintenance_handlers.rb b/chef/cookbooks/crowbar-pacemaker/files/default/pacemaker_maintenance_handlers.rb index 50f4f3d7..018ae03e 100644 --- a/chef/cookbooks/crowbar-pacemaker/files/default/pacemaker_maintenance_handlers.rb +++ b/chef/cookbooks/crowbar-pacemaker/files/default/pacemaker_maintenance_handlers.rb @@ -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. diff --git a/chef/cookbooks/crowbar-pacemaker/libraries/maintenance_mode_helpers.rb b/chef/cookbooks/crowbar-pacemaker/libraries/maintenance_mode_helpers.rb index 0cb93772..a501a82b 100644 --- a/chef/cookbooks/crowbar-pacemaker/libraries/maintenance_mode_helpers.rb +++ b/chef/cookbooks/crowbar-pacemaker/libraries/maintenance_mode_helpers.rb @@ -68,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 diff --git a/chef/cookbooks/pacemaker/attributes/default.rb b/chef/cookbooks/pacemaker/attributes/default.rb index 1cf1688e..f6f7aa27 100644 --- a/chef/cookbooks/pacemaker/attributes/default.rb +++ b/chef/cookbooks/pacemaker/attributes/default.rb @@ -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) default[:pacemaker][:platform][:sbd_packages] = %w(sbd) else