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

Mongo 4.0: Could not evaluate: Can't connect to any member of replicaset rs0 #517

Closed
piotrp opened this issue Nov 28, 2018 · 4 comments · Fixed by #535
Closed

Mongo 4.0: Could not evaluate: Can't connect to any member of replicaset rs0 #517

piotrp opened this issue Nov 28, 2018 · 4 comments · Fixed by #535

Comments

@piotrp
Copy link

piotrp commented Nov 28, 2018

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 6.0.4
  • Ruby: 2.5.1p57
  • Distribution: Ubuntu 16.04
  • Module version: 2.4.1

How to reproduce (e.g Puppet code you use)

$port = 27017

ensure_packages('apt-transport-https')

class { 'mongodb::globals':
  manage_package_repo => true,
  version             => '4.0.4',
  bind_ip             => ['0.0.0.0'],
  service_ensure      => running
}

class { 'mongodb::server':
  verbose        => true,
  restart        => true,
  port           => $port,
  journal        => true,
  pidfilepath    => '/var/run/mongodb/mongod.pid', # puppet-mongodb 2.4.1 incorrectly defines pidFilePath as /var/run/mongod.pid
  manage_pidfile => false, # a) makes no sense, because /run is temporary, and b) it fails anyway, because this class doesn't work if pid file is in a subdirectory
  replset        => 'rs0'
}

class { 'mongodb::client': } # required, or mongodb_replset will fail with "Request failed: 'Command mongo is missing'"

mongodb_replset { rs0:
  ensure  => present,
  members => ["${::fqdn}:${port}"]
}

What are you seeing

Error: "Can't connect to any member of replicaset rs0."

What behaviour did you expect instead

Replica set should be set up.

Output log

Attached: puppet.log

Any additional information you'd like to impart

Looks like message in 4.0 changed and result doesn't match what mongodb_replset expects:

root@bd1:/etc/puppet# /usr/bin/mongo admin --quiet --host bd1.dev:27017 --eval 'printjson(rs.status())'
{
        "operationTime" : Timestamp(0, 0),
        "ok" : 0,
        "errmsg" : "no replset config has been received",
        "code" : 94,
        "codeName" : "NotYetInitialized",
        "$clusterTime" : {
                "clusterTime" : Timestamp(0, 0),
                "signature" : {
                        "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
                        "keyId" : NumberLong(0)
                }
        }
}

It doesn't contain set key, it appears only after I manually issue rs.initiate().

@mrmikeace
Copy link

I have exactly the same issue.

@radupantiru
Copy link
Contributor

I have the same problem for version 4. The replica set is not created.

@mrmikeace
Copy link

Here's what I have to do to get past this problem:

  1. Create three mongo servers with replset_members set in the ::mongodb::server resource.
  2. Notice the "can't connect to any member of replicaset rsmain" error.
  3. SSH into the machine that will become the first member of the replset.
  4. I run rs.initiate() and rs.reconfig() manually to get the replicaset working.
  5. Rereun puppet on each server, and notice no errors.

@radupantiru
Copy link
Contributor

radupantiru commented Apr 8, 2019

Created a PR with the fix, although when using the master branch instead of the tag 2.4.1 in my Puppetfile during the puppet run I am getting:
Error: Failed to apply catalog: undefined local variable or method `n' for Puppet::Type::Mongodb_replset::ProviderMongo:Class Did you mean? n_ N_
I have created my branch from v2.4.1 and it runs just fine for my Mongo v4 replica set.

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

Successfully merging a pull request may close this issue.

4 participants