config_replicaset fails: Could not connect to database uninitialized constant Mongo::ConnectionFailure
gdegremont-purch opened this issue · 4 comments
My cookbook set a bunch of attributes (mostly specifying port number, replicaset name and cluster name) then calls:
include_recipe "mongodb::10gen_repo"
include_recipe "mongodb::replicaset"
The chef-client does not return an error and the mongodb server is up, I can connect to it, but replicaset is not configured and rs.status() gives me:
rs.status()
{
"startupStatus" : 3,
"info" : "run rs.initiate(...) if not yet done for the set",
"ok" : 0,
"errmsg" : "can't get local.system.replset config from self or any seed (EMPTYCONFIG)"
}
Looking at the logs, I see the following:
- execute the ruby block run_config_replicaset
[2015-04-24T22:27:35+00:00] INFO: ruby_block[run_config_replicaset] sending create action to ruby_block[config_replicaset] (delayed)
* ruby_block[config_replicaset] action create
[2015-04-24T22:27:35+00:00] INFO: Processing ruby_block[config_replicaset] action create (mongodb::replicaset line 225)
[2015-04-24T22:27:35+00:00] DEBUG: Platform centos version 6.6 found
[2015-04-24T22:27:36+00:00] WARN: Could not connect to database: 'localhost:27018', reason: uninitialized constant Mongo::ConnectionFailure
[2015-04-24T22:27:36+00:00] INFO: ruby_block[config_replicaset] called
I had the same problem. Mongo::MongoClient is no longer available in the mongo gem as of the 2.X release series. Try the fix in https://github.com/edelight/chef-mongodb/pull/384/files as that's what worked for me.
You have to pin the version of mongo rubygem to one that is compatible with the call this cookbook makes, and then make sure to remove the newer mongo version 2 gem from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems. After you do that, try another chef-client run.
I pinned the mongo rubygem to latest 1.x version (1.12.1) and it now works.
Thanks for your help.
Hi guys ,
This issue took a lot of our time to track down . We've upgraded to Chef 12 and suddenly "ruby block config_replicaset" stopped doing its job , without any slight indication , warning or error message . It literally looks like this in chef-client run :
Recipe: mongodb::replicaset
* ruby_block[config_replicaset] action create
- execute the ruby block config_replicaset
Running handlers:
Running handlers complete
Chef Client finished, 5/329 resources updated in 11 seconds
The only indication of an issue is replicaset configs not updated on node provisioning / removal .
Finally we tracked this down by running chef-client -l debug
and looking at /var/log/chef/client.log
and seeing the error message above .
I think config_replicaset
should be causing chef-client run to fail on the event it can't do its job .
This cookbook is old and unmaintained, so in case of trouble when using it, please check for issues in this bugtracker and the one on the cookbook fork (https://github.com/chef-brigade/mongodb-cookbook): common issues are often documented with either a workaround or "there is currently no solution, please help us".