-
Notifications
You must be signed in to change notification settings - Fork 423
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
[#125] - Enhancing clustering functionality #238
Conversation
Transfering rabbitmq-cluster cookbook into rabbitmq cookbook * Changing attribute prefix : [:rabbitmq-cluster] to [:rabbitmq][:clustering] * Enhancement on regex : user ruby matcher * Removing unnecessary resource : node_type on change_cluster_node_type action * Some other enhancement on provider Enhancing from rabbitmq-cluster as the manual clustering * Removing master/slave concept * Removing cluster node type * Introducing new attribute that defines all the cluster nodes and its cluster node type : `[:rabbitmq][:clustering][:cluster_nodes]` * Adding set_cluster_name action Applying new features and attributes into auto clustring * Using `default[:rabbitmq][:clustering][:cluster_nodes]` attribute instead of `['rabbitmq']['cluster_disk_nodes']` * Applying set_cluster_name and change_cluster_node_type for auto clustering * Long story short, All the nodes will be set as `disc` node in the rabbitmq.config even though you have some ram nodes. however, change_cluster_node_type action will fix the node type as you expected. Additional changes on the others * Fixing typo in default receipe for stopping service to set erlang cookie Attributes example ``` default[:rabbitmq][:clustering][:use_auto_clustering] = false default[:rabbitmq][:clustering][:cluster_name] = 'seoul_tokyo_newyork' default[:rabbitmq][:clustering][:cluster_nodes] = [ { :name => 'rabbit@rabbit1', :type => 'disc' }, { :name => 'rabbit@rabbit2', :type => 'ram' }, { :name => 'rabbit@rabbit3', :type => 'disc' } ] ``` Redesign of manual clustering - remove master/slave - remove cluster node type for each node - introducing new attribute that defines all the cluster nodes and its cluster node type - adding set_cluster_name feature - preparing of auto clustering in cluster recipe Adding set cluster name action for manual clustering. Apply [:rabbitmq][:clustering][:cluster_nodes] attribute on rabbitmq.config fix typo Apply set_cluster_name and change_cluster_node_type for auto clustering
Thank you for taking the time to work on this. I am taking a look through it now. Can you fix the style issues that travis is complaining about? Also I think we might want to a section to the README describing how to use these changes. |
@cmluciano |
- Fix some code to handle style issue.
@cmluciano I fixed style issue and rubocop issue. and Travis has passed. please review it. |
# execute > rabbitmqctl cluster_status | sed "1d" | tr "\n" " " | tr -d " " | ||
# rabbitmqctl cluster_status returns "Cluster status of node rabbit@rabbit1 ..." at the first line. | ||
# To parse the result string, it is removed by sed "1d" | ||
cmd = 'rabbitmqctl cluster_status | sed "1d" | tr "\n" " " | tr -d " "' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused by the need to pipe to sed, tr. etc. Is this to try to normalize the output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah i have to parrot @cmluciano here, this cmd
scares me. Is there a way we could leverage some ruby or something other then sed
tr
tr
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that is for normalize the output. because, rabbitmqctl output, mostly indent and line feed, was different from servers and versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'l try with ruby.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be changed like this.
def cluster_status
# execute > rabbitmqctl cluster_status"
# To parse the result string, this function normalize the output string
# - Removing first line
# - Removing "... Done" : old version returns this
cmd = 'rabbitmqctl cluster_status'
Chef::Log.debug("[rabbitmq_cluster] Executing #{cmd}")
cmd = get_shellout(cmd)
cmd.run_command
cmd.error!
result = cmd.stdout.split(/\n/, 2).last.squeeze(' ').gsub(/\n/, '').gsub('...done.', '')
Chef::Log.debug("[rabbitmq_cluster] rabbitmqctl cluster_status : #{result}")
result
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
- Using ruby code instead of linux command : `sed`, `tr` has removed. - Fixing english grammar - Removing `json` tag from README : its not from the code review result
@jjasghar @cmluciano |
I restarted it, lets see if it passes. |
@jjasghar Looks good! |
👍 |
# Join in cluster | ||
rabbitmq_cluster cluster_nodes do | ||
action :join | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this unless
block be a not_if {}
in the resource call instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jesseadams
node['rabbitmq']['clustering']['use_auto_clustering']
is the flag for using auto clustering or manual clustering. should I use not_if
? can you please explain to me how not_if
different from unless
at this code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is fundamentally the same. I thought that not using not_if was a FoodCritic violation in this case. Maybe not?
Can we please get this reviewed once more and merged? Thanks! |
Transfering rabbitmq-cluster cookbook into rabbitmq cookbook
Enhancing from rabbitmq-cluster as the manual clustering
[:rabbitmq][:clustering][:cluster_nodes]
Applying new features and attributes into auto clustring
default[:rabbitmq][:clustering][:cluster_nodes]
attribute instead of['rabbitmq']['cluster_disk_nodes']
disc
node in the rabbitmq.config even though you have some ram nodes. however, change_cluster_node_type action will fix the node type as you expected.Additional changes on the others
Attributes example