From ccfcaf086d5748b28ed710cb64b21ea66e4112fd Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 7 Sep 2015 10:30:32 +0100 Subject: [PATCH] prevent clusters with an even number of nodes Clusters must have an odd number of nodes to ensure quorum during partitioning. 2-node clusters are allowed as a special exception for the typical DRBD setup. --- crowbar_framework/app/models/pacemaker_service.rb | 6 ++++++ crowbar_framework/config/locales/pacemaker/en.yml | 3 +++ 2 files changed, 9 insertions(+) diff --git a/crowbar_framework/app/models/pacemaker_service.rb b/crowbar_framework/app/models/pacemaker_service.rb index 83a71d78..d25bbf71 100644 --- a/crowbar_framework/app/models/pacemaker_service.rb +++ b/crowbar_framework/app/models/pacemaker_service.rb @@ -510,6 +510,12 @@ def validate_proposal_after_save proposal elements = proposal["deployment"]["pacemaker"]["elements"] members = elements["pacemaker-cluster-member"] || [] + if members.length.even? && members.length > 2 + validation_error I18n.t( + "barclamp.#{bc_name}.validation.cluster_size_even" + ) + end + if elements.key?("hawk-server") elements["hawk-server"].each do |n| @logger.debug("checking #{n}") diff --git a/crowbar_framework/config/locales/pacemaker/en.yml b/crowbar_framework/config/locales/pacemaker/en.yml index 6dd34f02..e3475d81 100644 --- a/crowbar_framework/config/locales/pacemaker/en.yml +++ b/crowbar_framework/config/locales/pacemaker/en.yml @@ -124,3 +124,6 @@ en: quorum_policy: 'Invalid no-quorum-policy value: %{no_quorum_policy}.' platform: 'All nodes in proposal must have the same platform.' pacemaker_proposal: 'Nodes cannot be part of multiple Pacemaker proposals, but %{other_member} is already part of proposal \"%{p_name}\".' + cluster_size_even: + 'Clusters must have an odd number of nodes to ensure quorum during + partitioning. 2-node clusters are allowed as a special exception.'