rueckstiess / mtools

A collection of scripts to set up MongoDB test environments and parse and visualize MongoDB log files.
Apache License 2.0
1.89k stars 404 forks source link

mlaunch with --auth fails to run #855

Closed kelly-cs closed 2 years ago

kelly-cs commented 2 years ago

Expected behavior

Launch cluster using mlaunch start

Actual/current behavior

attempting to load mlaunch using the --auth parameter on WSL Ubuntu 20.04. It leads to an error in mongos (it puts --auth after mongos which is invalid in .mlaunch_startup). mlaunch init --nodes 2 --sharded 1 --replicaset --auth

mlaunch start
launching: config server on port 27020
launching: "mongod" on port 27018
launching: "mongod" on port 27019
b"Error parsing command line: unrecognised option '--auth'\ntry 'mongos --help' for more information\n"

can't start process, return code 2. tried to launch: mongos --logpath "/home/likai/tickets/server-64549/data/mongos.log" --port 27017 --configdb configRepl/localhost:27020 --auth --keyFile "/home/likai/tickets/server-64549/data/keyfile"   --fork

... when --auth is removed from .mlaunch_startup on the line executing mongos, It will hang at the point it launches mongos in terminal:

mlaunch start
launching: config server on port 27020
launching: "mongod" on port 27018
launching: "mongod" on port 27019
(hangs)

...and then the mongos.log repeats the following over and over:

{"t":{"$date":"2022-03-28T17:00:36.381-04:00"},"s":"W",  "c":"SHARDING", "id":23834,   "ctx":"mongosMain","msg":"Error initializing sharding state, sleeping for 2 seconds and retrying","attr":{"error":{"code":133,"codeName":"FailedT
oSatisfyReadPreference","errmsg":"Error loading clusterID :: caused by :: Could not find host matching read preference { mode: \"nearest\" } for set configRepl"}}}

When I remove --auth from the mlaunch init and try again, everything works. mlaunch init --nodes 2 --sharded 1 --replicaset

Steps to reproduce the actual/current behavior

do mlaunch init with --auth on it mlaunch init --nodes 2 --sharded 1 --replicaset --auth

Environment

This has been reproduced on WSL 2 on Windows 10, 11 (running Ubuntu 20,04 LTS) and Ubuntu 18.04 in Evergreen.

kelly-cs commented 2 years ago

575d188366cbb1101201a27087ad2376456dcf27 https://github.com/rueckstiess/mtools/commit/575d188366cbb1101201a27087ad2376456dcf27 hang persists but doesn't have keyfile error complaint on init 769d2f53d691ca4e65487b4c187d3a66ad85b0fd https://github.com/rueckstiess/mtools/commit/769d2f53d691ca4e65487b4c187d3a66ad85b0fd same thing

kelly-cs commented 2 years ago

eventually spits this out to terminal pymongo.errors.ServerSelectionTimeoutError: No servers match selector "Primary()", Timeout: 0.001s, Topology Description: <TopologyDescription id: 624369d1cbb3ac940e3b85f7, topology_type: Unknown, servers: [<ServerDescription ('localhost', 27020) server_type: RSGhost, rtt: 0.0002847499999916181>]>

stennie commented 2 years ago

@kelly-cs I suspect this is related to changes in mtools 1.7.0 to use PyMongo 4 (and possibly same issues as #849).

A quick fix worth trying would be installing PyMongo 3: pip3 install pymongo=3.12.2

The PyMongo 4 and --auth issues will be addressed in a 1.7.1 bug fix release.

Regards, Stennie

kelly-cs commented 2 years ago

That did the trick. Thanks!