Skip to content
This repository was archived by the owner on Dec 4, 2018. It is now read-only.
Closed
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 @@ -19,6 +19,26 @@ module CrowbarPacemaker
# Chef::Provider::PacemakerService LWRP.
module MaintenanceModeHelpers
def maintenance_mode?
# For once, we want 2>&1 to come before >/dev/null, not after!
cibadmin = %x(cibadmin -Ql 2>&1 >/dev/null)
case cibadmin
when /Connection refused/
# Cluster is not up, so let things proceed so that Chef can
# start it if appropriate.
return false
when /command not found/
# pacemaker has been deinstalled?
return false
end

if ! $?.success?
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

unless $?.success?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I really don't like multi-line unless - I find it more effort for the brain to understand.

Chef::Log.warn("cibadmin -Ql failed when checking Pacemaker maintenance mode!")
Chef::Log.warn(cibadmin)
Chef::Log.warn("Something wrong, so treating as if in maintenance " +
"mode; will need manual intervention.")
return true
end

!! (%x(crm node show #{node.hostname}) =~ /maintenance:\s*on/)
end

Expand Down