Skip to content

Commit

Permalink
pacemaker: remove node on delete (SOC-11240)
Browse files Browse the repository at this point in the history
On node delete, crowbar doesn't execute pacemaker barclamp due to
default pacemaker proposal not having transitions attribute enabled
for delete. Next, pacemaker needs to remove the node from the cluster
prior to being deleted from crowbar. This change adds said feature.
  • Loading branch information
sandonovsuse committed Aug 27, 2020
1 parent e6f67e1 commit 25d4627
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
5 changes: 2 additions & 3 deletions chef/data_bags/crowbar/template-pacemaker.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,8 @@
"config": {
"environment": "pacemaker-base-config",
"mode": "full",
"transitions": false,
"transition_list": [
]
"transitions": true,
"transition_list": [ "delete" ]
}
}
}
Expand Down
28 changes: 28 additions & 0 deletions crowbar_framework/app/models/pacemaker_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,34 @@ def prepare_stonith_attributes(role_attributes, remote_nodes, member_nodes, remo
end
end

def transition(inst, name, state)
@logger.debug("Pacemaker transition: entering: #{name} for #{state}")

if state == "delete"
proposal = Proposal.find_by(barclamp: @bc_name, name: inst)
stonith_mode = proposal["attributes"]["pacemaker"]["stonith"]["mode"]

# remove node from stonith cfg
proposal["attributes"]["pacemaker"]["stonith"][
stonith_mode]["nodes"].delete(name)
if proposal["attributes"]["pacemaker"]["stonith"]["per_node"]["nodes"]
proposal["attributes"]["pacemaker"]["stonith"][
"per_node"]["nodes"].delete(name)
end

# remove from pacemaker-cluster-member
proposal["deployment"]["pacemaker"]["elements"][
"pacemaker-cluster-member"].delete(name)

# Save and commit
proposal.save
proposal_commit(inst, in_queue: false, validate: false, validate_after_save: false)
end

@logger.debug("Pacemaker transition: exiting: #{name} for #{state}")
[200, { name: name }]
end

private

def pacemaker_node_name(node, remotes)
Expand Down

0 comments on commit 25d4627

Please sign in to comment.