-
Notifications
You must be signed in to change notification settings - Fork 228
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
Use Chef search (role:cassandra) to look up seed nodes #205
Conversation
If search is not available, we fall back to using node's own IP address by default. Fixes #204.
@vkhatri please take a look. |
I may be mis-understanding, but won't this add a chef search to every client run, even when you're not using the default value? Also, it's generally preferable to not have every node in your cluster be a seed, but only use a subset. That's why I use a search for a tag |
@sethrosenblum good points. Perhaps we should move this to the recipe and check if |
One way of making search optional would be using separate recipes for that (instead of adding more conditional attributes). |
@sethrosenblum @vkhatri I've moved seed discovery into a separate recipe. Let me know what you think. |
@michaelklishin sorry for the delay. this looks nice, few thoughts:
please let me know what do you think |
@vkhatri OK, I guess this is a philosophical decision more than a technical one. I'll do what you suggest. I'm now sure what you mean by
Discovering cluster name is a good idea. Do you mean that we should do this regardless of the |
@michaelklishin only if templates/default/cassandra.yaml.erb: - seeds: "<%= eval_seed_nodes %>" seed helper method: def eval_seed_nodes
# use chef search for seed nodes
if node['cassandra']['seed']['use_chef_search']
if Chef::Config[:solo]
Chef::Log.warn("Chef Solo does not support search, provide the seed nodes via node attribute node['cassandra']['seeds']")
node['ipaddress']
else
if node['cassandra']['seed']['search_query']
# user defined search query
xs = search(:node, node['cassandra']['seed']['search_query']).map(&:ipaddress).sort.uniq
else
# cookbook auto search query
search_query = "chef_environment:#{node.chef_environment} AND role:#{node['cassandra']['seed']['search_role']} AND cassandra_cluster_name:#{node['cassandra']['cluster_name']}"
xs = search(:node, search_query).map(&:ipaddress).sort.uniq
end
if xs.empty?
node['ipaddress']
else
xs.take(node['cassandra']['seed']['count']).join(',')
end
end
else
# user defined seed nodes
if node['cassandra']['seeds'].is_a?(Array)
node['cassandra']['seeds'].join(',')
else
node['cassandra']['seeds']
end
end
end attributes: default['cassandra']['seed']['use_chef_search'] = false
default['cassandra']['seed']['count'] = 3
default['cassandra']['seed']['search_role'] = 'cassandra-seed'
default['cassandra']['seed']['search_query'] = nil |
@vkhatri fair enough, I'll take your suggestion and run with it. |
@vkhatri @sethrosenblum ready for another round. |
I'm getting an exception that says method |
OK, I can confirm that seed discovery using Chef search and a custom query now works well in my environment. |
@michaelklishin LGTM 👍 |
Use Chef search (role:cassandra) to look up seed nodes
If search is not available, we fall back to using node's own
IP address by default.
Fixes #204.