-
Notifications
You must be signed in to change notification settings - Fork 3
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
Abstract away chef search for discovery #215
Comments
I like this idea as it helps us move the cookbook away from chef-search dependency (I thought chef-zero now deals with this a bit?). anyways, I am for moving discovery out from being so tightly integrated with the cookbook. |
Looking at serf, it seems we won't be able to easily use serf for discovery until 0.4 is released, it adds key-value tags which we can use to get the |
After significant investigation, I've begun working on a project called Because replicaset configuration requires a number of attributes about each hosts, a simple string array won't do the trick. So discoteq provides service data of the form: {
"services": {
"mongodb": [
{
"hostname": "mongodb-001.example.net ",
"port": 27017,
"arbiterOnly": false
},
{
"hostname": "mongodb-002.example.net ",
"port": 27017,
"arbiterOnly": false
},
{
"hostname": "mongodb-003.example.net ",
"port": 27017,
"arbiterOnly": true
}
]
}
} I'm still locking down the syntax for configuring the lib. At the moment, it supports a JSON config like the following: {
"query_map": {
"myface-fascade": {
"type": "explicit",
"records": [
{
"hostname": "myface-lb.example.net"
}
]
},
"mongodb": {
"type": "chef_query",
"query": "(role:mongodb AND tag:awsm)"
"attrs": {
"host: "cloud.private_ipv4",
"port": "mongodb.port"
}
},
"myface-cache": {
"type": "chef_role"
}
}
} The above allows for an explicit member set, an arbitrary chef search query with arbitrary node attributes, and a very simple role query (query: I haven't yet locked down a shorthand syntax for storing in this in node attributes yet. |
chef-zero with client provided attributes first yeh? |
I would kill to be able to simply specify the information this cookbook needs to setup a replica set. I am quite able to provide a role which gives the information needed by this cookbook. While trying to integrate this with Coopr, I ran into this search issue. Requiring |
Moved to sous-chefs/sc-mongodb#77 |
Chef Search is used for three purposes in this cookbook:
While chef search is great for a good out-of-the-box experience, it's actually quite poorly suited to the task of configuring a database cluster:
Additionally, our use of search has other problems:
Considering all those issues, we should strive to isolate our use of chef-search for discovery. To tackle this, we'll need to:
Improve Library, Definition & Resource APIs
Pull access to node objects out from library functions, and ultimately out of the
mongodb_instance
definition so wrapper cookbooks can provide alternative discovery methods. These should be possible while remaining backwards compatible.This should require refactoring
MongoDB::configure_replicaset
andMongoDB::configure_shards
to accept a mere array of strings as node identifiers. To do this,mongodb_instance
will need to extract the correct attributes for each node.With this done, that logic will need to be pulled up into the cookbooks which call
mongodb_instance
. At this point, it will probably be useful to create a helper library to abstract this discovery. I suggest we model this library aftersearch_for_nodes
from the elasticsearch cookbook, and the discovery cookbook from Heavywater.Improve cookbook API
Define a set of node attributes which allow overriding discovery for most use cases:
fqdn
attribute from each matched nodescloud.local_ipv4
attribute from each matched nodescloud. public_ipv4
attribute from each matched nodesipaddress
attributes from each matched nodesI suggest we model our use of attributes after search in the elasticsearch cookbook, which uses:
node['elasticsearch']['discovery']['search_query']
- which defaults toroles:elasticsearch AND chef_environment:#{node.chef_environment} AND elasticsearch_cluster_name:#{node[:elasticsearch][:cluster][:name]}"
node['elasticsearch']['discovery']['node_attribute']
- which defaults tocloud.local_ipv4
if it exists, oripaddress
This implies the following :
node['elasticsearch']['discovery']['search_query']
- which defaults toroles:elasticsearch AND chef_environment:#{node.chef_environment} AND elasticsearch_cluster_name:#{node[:elasticsearch][:cluster][:name]}"
node['elasticsearch']['discovery']['node_attribute']
- which defaults tocloud.local_ipv4
if it exists, oripaddress
The text was updated successfully, but these errors were encountered: