Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crowbar: Self-heal if node is missing its node role in the run list #1565

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
14 changes: 11 additions & 3 deletions crowbar_framework/app/models/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def initialize(node, role = nil)
raise Crowbar::Error::NotFound.new
end
end
Node.ensure_node_role(node, @role.name)
# deep clone of @role.default_attributes, used when saving node
@attrs_last_saved = @role.default_attributes.deep_dup
@node = node
Expand Down Expand Up @@ -1701,13 +1702,20 @@ def create_new_role(new_name, machine)
role.default_attributes["crowbar"]["network"] = {}
role.save

# This run_list call is to add the crowbar tracking role to the node. (SAFE)
machine.run_list.run_list_items << "role[#{role.name}]"
machine.save
Node.ensure_node_role(machine, role.name)

role
end

def ensure_node_role(node, role_name = nil)
role_name = make_role_name(node.name) if role_name.nil?
return if node.run_list.include?("role[#{role_name}]")

# This run_list call is to add the crowbar tracking role to the node. (SAFE)
node.run_list << "role[#{role_name}]"
node.save
end

def create_new(new_name)
machine = Chef::Node.new
machine.name "#{new_name}"
Expand Down