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.
Migartion also added.
  • Loading branch information
sandonovsuse committed Oct 29, 2020
1 parent e6f67e1 commit 6e1a375
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def upgrade(template_attrs, template_deployment, attrs, deployment)
deployment["config"]["transition_list"] = template_deployment["config"]["transition_list"]
deployment["config"]["transitions"] = template_deployment["config"]["transitions"]
return attrs, deployment
end

def downgrade(template_attrs, template_deployment, attrs, deployment)
deployment["config"]["transition_list"] = template_deployment["config"]["transition_list"]
deployment["config"]["transitions"] = template_deployment["config"]["transitions"]
return attrs, deployment
end
7 changes: 3 additions & 4 deletions chef/data_bags/crowbar/template-pacemaker.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"pacemaker": {
"crowbar-revision": 0,
"crowbar-applied": false,
"schema-revision": 301,
"schema-revision": 302,
"element_states": {
"pacemaker-cluster-member" : [ "readying", "ready", "applying" ],
"hawk-server" : [ "readying", "ready", "applying" ],
Expand All @@ -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 6e1a375

Please sign in to comment.