sous-chefs / sc-mongodb

Development repository for the sc-mongodb cookbook
https://supermarket.chef.io/cookbooks/sc-mongodb
Apache License 2.0
75 stars 92 forks source link

Facing 400 "Bad Request" when trying to configure a replica #178

Open JustLeo opened 6 years ago

JustLeo commented 6 years ago

Hello, I'm trying to configure a replica using the cookbook but it fails when autoconfigure is set to true giving me the following error message:

================================================================================ Recipe Compile Error in /var/chef/cache/cookbooks/sc-mongodb/recipes/replicaset.rb

Net::HTTPServerException

400 "Bad Request"

Cookbook Trace:

/var/chef/cache/cookbooks/sc-mongodb/definitions/mongodb.rb:236:in block in from_file' /var/chef/cache/cookbooks/sc-mongodb/recipes/replicaset.rb:36:infrom_file'

Relevant File Content:

/var/chef/cache/cookbooks/sc-mongodb/definitions/mongodb.rb:

229: notifies :create, 'ruby_block[config_sharding]', :immediately if new_resource.is_mongos && new_r esource.auto_configure_sharding 230: # we don't care about a running mongodb service in these cases, all we need is stopping it 231: ignore_failure true if new_resource.name == 'mongodb' 232: end 233: 234: # replicaset 235: if new_resource.is_replicaset && new_resource.auto_configure_replicaset 236>> rs_nodes = search( 237: :node, 238: "mongodb_cluster_name:#{new_resource.cluster_name} AND "\ 239: 'mongodb_is_replicaset:true AND '\ 240: "mongodb_config_mongod_replication_replSetName:#{new_resource.replicaset_name} AND "\ 241: "chef_environment:#{node.chef_environment}" 242: ) 243: 244: ruby_block 'config_replicaset' do 245: block do

Platform:

x86_64-linux

What am I missing here? from where this cookbook is getting/generating the replicaset_name? Any help will be appreciated.

Thanks,

Leo

wdeviers commented 6 years ago

I haven't investigated farther but at the time of 1.0.0 you have to set it yourself, even though the docs don't indicate as such:

"mongodb": { "cluster_name": "wesawesomecluster", "config": { "mongod": { "replication": { "replSetName": "wesawesomeset" } } } }

I would expect the replica set name to inherit from the cluster name if shards aren't configured.
github-actions[bot] commented 4 years ago

Marking stale due to inactivity. Remove stale label or comment or this will be closed in 7 days. Alternatively drop by the #sous-chefs channel on the Chef Community Slack and we'll be happy to help! Thanks, Sous-Chefs.