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

removed mongo cli in 6.0 is not compatible with outputs from new mongosh #648

Closed
tsgoff opened this issue Jul 28, 2022 · 4 comments · Fixed by #703
Closed

removed mongo cli in 6.0 is not compatible with outputs from new mongosh #648

tsgoff opened this issue Jul 28, 2022 · 4 comments · Fixed by #703

Comments

@tsgoff
Copy link

tsgoff commented Jul 28, 2022

Affected Puppet, Ruby, OS and module versions/distributions

  • Distribution: 6.0
  • Module version: v.4.1.1

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

  class { '::mongodb::globals':
    manage_package_repo => true,
    version             => '6.0.0',
  }

What are you seeing

Error: /Stage[main]/Mongodb::Replset/Mongodb_replset[mongodb.int]: Could not evaluate: Can't connect to any member of replicaset mongodb.int.
Error: Failed to apply catalog: Could not evaluate MongoDB shell command: load('/root/.mongorc.js'); try { rs.secondaryOk() } catch (err) { rs.slaveOk() };printjson(db.getMongo().getDBs())

mongodb_version.rb: mongodb_version = Facter::Core::Execution.execute('mongo --version 2>&1')
is_master.rb: Facter::Core::Execution.exec("mongo --quiet #{options} --eval "#{e}printjson(db.adminCommand({ ping: 1 }))"")

replset_spec.rb: on hosts_as('slave'), %{mongo test --verbose --eval 'load("/root/.mongorc.js");try { rs.secondaryOk() } catch (err) { rs.slaveOk() };printjson(db.dummyData.findOne())'}

What behaviour did you expect instead

Output log

Any additional information you'd like to impart

The old mongo cli is used in the ruby scripts to configure the mongo db. The outputs of mongosh are not compatible with the expected outputs.
What would be the suggested way to adjust this? Rework all scripts to work with mongosh output and implement a condition for version > 5.0.9?

@ghost
Copy link

ghost commented Dec 1, 2022

  1. mongo cli renamed to mongosh, provider should call this binary (workaround: ln -s mongosh /usr/bin/mongo )
  2. rs.secondaryOk() calls, return:
    DeprecationWarning: .setSecondaryOk() is deprecated. Use .setReadPref("primaryPreferred") instead
    fix (?): use db.getMongo().setReadPref("secondaryPreferred")

@tsgoff
Copy link
Author

tsgoff commented Dec 2, 2022

  1. mongo cli renamed to mongosh, provider should call this binary (workaround: ln -s mongosh /usr/bin/mongo )
  2. rs.secondaryOk() calls, return:
    DeprecationWarning: .setSecondaryOk() is deprecated. Use .setReadPref("primaryPreferred") instead
    fix (?): use db.getMongo().setReadPref("secondaryPreferred")

In version 5 are both mongo cli and mongosh installed. In version 6 you cannot install mongo cli. A symlink does not work because the output is different.

@pbsladek
Copy link

pbsladek commented Apr 12, 2023

ln -s mongosh /usr/bin/mongo kinda works for me on 6. Also symlink the mongosh config. So i can get around the errors above.. but it leads to new errors.

While the db can be finally configured via cmdline to work around the module issues.. puppet won't run at least for replset.

Error: Could not prefetch mongodb_replset provider 'mongo': 765: unexpected token at '{
  _id: 'rsxxx',
  version: 5,
  term: 1,
  members: [
    {

Would love to get some module updates to support mongosh and 6.X out of the box.

@witjoh
Copy link
Contributor

witjoh commented Jul 7, 2023

#677
This PR only uses mongosh, and works on redhat for now for mongodb 6.x version.
Still work in process.

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