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

[#125] - Enhancing clustering functionality #238

Merged
merged 4 commits into from
Apr 24, 2015

Conversation

sunggun-yu
Copy link
Contributor

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'
    }
]

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
@cmluciano
Copy link

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.

@sunggun-yu
Copy link
Contributor Author

@cmluciano
Sure, I will.

@sunggun-yu
Copy link
Contributor Author

@cmluciano I fixed style issue and rubocop issue. and Travis has passed. please review it.
Thank you.

# 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 " "'

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?

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jjasghar @cmluciano

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

Copy link
Contributor

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
@sunggun-yu
Copy link
Contributor Author

@jjasghar @cmluciano
seems like,,,, Travis has been stopped by connection timed out...
https://travis-ci.org/jjasghar/rabbitmq/builds/53843704

@jjasghar
Copy link
Contributor

I restarted it, lets see if it passes.

@sunggun-yu
Copy link
Contributor Author

@jjasghar Looks good!

@jesseadams
Copy link

👍

# Join in cluster
rabbitmq_cluster cluster_nodes do
action :join
end

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?

Copy link
Contributor Author

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?

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?

@jesseadams
Copy link

Can we please get this reviewed once more and merged? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants