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

Fix change node type #263

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 16 additions & 4 deletions providers/cluster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ def match_pattern_cluster_status(cluster_status, pattern)
Chef::Application.fatal!('[rabbitmq_cluster] cluster_status should not be empty')
end
match = cluster_status.match(pattern)
match[2]
if match.nil?
match
else
match[2]
end
end

# Get currently joined cluster name from result string of "rabbitmqctl cluster_status"
Expand All @@ -89,15 +93,23 @@ def disc_nodes(cluster_status)
pattern = '({disc,\[)(.*?)(\]})'
result = match_pattern_cluster_status(cluster_status, pattern)
Chef::Log.debug("[rabbitmq_cluster] disc_nodes : #{result}")
result.split(',')
if result.nil?
result = []
Copy link
Contributor

Choose a reason for hiding this comment

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

Rubocop doesn't like this :(

else
result.split(',')
end
end

# Get ram nodes
def ram_nodes(cluster_status)
pattern = '({ram,\[)(.*?)(\]})'
result = match_pattern_cluster_status(cluster_status, pattern)
Chef::Log.debug("[rabbitmq_cluster] ram_nodes : #{result}")
result.split(',')
if result.nil?
result = []
Copy link
Contributor

Choose a reason for hiding this comment

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

Rubocop doesn't like this :(

else
result.split(',')
end
end

# Get node name
Expand Down Expand Up @@ -227,7 +239,7 @@ def change_cluster_node_type(cluster_node_type)
var_cluster_status = cluster_status
var_node_name = node_name
var_current_cluster_node_type = current_cluster_node_type(var_node_name, var_cluster_status)
var_cluster_node_type = parse_cluster_nodes_string(new_resource.cluster_nodes).select { |node| node['name'] == var_node_name }.first['type'] # ~FC039
var_cluster_node_type = parse_cluster_nodes_string(new_resource.cluster_nodes).each { |node| node['name'] == var_node_name }.first['type'] # ~FC039

if var_current_cluster_node_type == var_cluster_node_type
Chef::Log.warn('[rabbitmq_cluster] Skip changing cluster node type : trying to change to same cluster node type')
Expand Down