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 403 forks source link

Server version-dependent argument processing is problematic #865

Closed p-mongo closed 2 years ago

p-mongo commented 2 years ago

mlaunch conditionally defines which options it supports based on server version that it is launching. Specifically it either uses tls names or ssl names.

This is problematic when mlaunch is used to launch various server versions, because it obligates mlaunch's clients to conditionally formulate arguments to mlaunch when mlaunch is aware of both types of arguments.

Worse, mlaunch simply ignores the ssl arguments which causes it to misbehave, specifically it launches deployment with wrong configuration:

[2022-05-17 18:39:02.104] + python3 -m mtools.mlaunch.mlaunch --dir /data/mci/69f54ee9edf83937fb4e49b51dbbac29/src/../drivers-tools/.evergreen/orchestration/db --binarypath /data/mci/69f54ee9edf83937fb4e49b51dbbac29/src/../drivers-tools/.evergreen/orchestration/mdb/mongodb-linux-x86_64-enterprise-ubuntu1604-4.4.14/bin --setParameter enableTestCommands=1 --setParameter diagnosticDataCollectionEnabled=false --single --sslMode requireSSL --sslPEMKeyFile spec/support/ocsp/ecdsa/server.pem --sslCAFile spec/support/ocsp/ecdsa/ca.crt --sslClientCertificate spec/support/ocsp/ecdsa/server.pem

[2022-05-17 18:39:04.963] warning: ignoring unknown argument --sslMode for /data/mci/69f54ee9edf83937fb4e49b51dbbac29/src/../drivers-tools/.evergreen/orchestration/mdb/mongodb-linux-x86_64-enterprise-ubuntu1604-4.4.14/bin/mongod
[2022-05-17 18:39:04.963] warning: ignoring unknown argument --sslPEMKeyFile for /data/mci/69f54ee9edf83937fb4e49b51dbbac29/src/../drivers-tools/.evergreen/orchestration/mdb/mongodb-linux-x86_64-enterprise-ubuntu1604-4.4.14/bin/mongod
[2022-05-17 18:39:04.963] warning: ignoring unknown argument --sslCAFile for /data/mci/69f54ee9edf83937fb4e49b51dbbac29/src/../drivers-tools/.evergreen/orchestration/mdb/mongodb-linux-x86_64-enterprise-ubuntu1604-4.4.14/bin/mongod
[2022-05-17 18:39:04.963] warning: ignoring unknown argument --sslClientCertificate for /data/mci/69f54ee9edf83937fb4e49b51dbbac29/src/../drivers-tools/.evergreen/orchestration/mdb/mongodb-linux-x86_64-enterprise-ubuntu1604-4.4.14/bin/mongod
[2022-05-17 18:39:04.963] launching: "/data/mci/69f54ee9edf83937fb4e49b51dbbac29/src/../drivers-tools/.evergreen/orchestration/mdb/mongodb-linux-x86_64-enterprise-ubuntu1604-4.4.14/bin/mongod" on port 27017

Since mlaunch is aware of both groups of arguments, I think it should accept both forms and translate to the correct one for the server being launched automatically.

I am also curious how mlaunch knows which of these groups of arguments to define, given that path to server is another argument - does the path have to be specified ahead of tls arguments or does tls argument processing gets delayed somehow?

p-mongo commented 2 years ago

Also note that servers through 6.0 recognize ssl arguments, e.g.

serene2% /usr/local/m/versions/6.0/mongod --sslMode x
{"t":{"$date":"2022-05-18T18:17:27.450Z"},"s":"W",  "c":"CONTROL",  "id":23322,   "ctx":"-","msg":"Option: sslMode is deprecated. Please use tlsMode instead."}
{"t":{"$date":"2022-05-18T18:17:27.451Z"},"s":"F",  "c":"CONTROL",  "id":20574,   "ctx":"-","msg":"Error during global initialization","attr":{"error":{"code":2,"codeName":"BadValue","errmsg":"unsupported value for tlsMode x"}}}

mlaunch is therefore rejecting valid server arguments for 4.4-6.0.

stennie commented 2 years ago

mlaunch conditionally defines which options it supports based on server version that it is launching. Specifically it either uses tls names or ssl names.

There are a few aspects to this:

SSL vs TLS options don't fix the expected pattern because:

I noticed your test suite is still using the deprecated --ssl options with 4.4. Do you still need to test on EOL versions of MongoDB, or could your incantations be updated to the modern --tls defaults?

p-mongo commented 2 years ago

Drivers support 3.6+ servers presently.

p-mongo commented 2 years ago

Workaround which appears to work through 6.0: https://github.com/p-mongodb/mtools-legacy/commit/886a2e50238a139ac3a206ab5f53779635d9d2a0