[SERVER-64852] mongod --outputConfig produces incorrect YAML option name (replSet vs. replSetName) Created: 23/Mar/22  Updated: 29/Oct/23  Resolved: 07/Aug/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 4.4.8, 5.0.5
Fix Version/s: 7.1.0-rc0

Type: Bug Priority: Major - P3
Reporter: Gary Taylor Assignee: Shreyas Kalyan
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Related
related to SERVER-65862 Automatically generate the config fil... Closed
Assigned Teams:
Server Security
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v7.0, v6.0, v5.0, v4.4
Steps To Reproduce:

 

https://www.mongodb.com/docs/manual/reference/program/mongod/#std-option-mongod.–replSet{{}}

Running: "mongod --replSet s0 --logpath "/data/logs/s0-r0.log" --dbpath /data/shard0/rs0 --bind_ip_all --port 37017 --fork --outputConfig" produces the following YAML output. 

Output below (generated by --outputConfig) to be used as a mongod configuration file.

net:
bindIp: "*"
port: 37017
outputConfig: true
processManagement:
fork: true
replication:
replSet: s0
storage:
dbPath: /data/shard0/rs0
systemLog:
destination: file
path: /data/logs/s0-r0.log

However, if you use this output as a configuration file, mongod will not start as you get the following error:

"Unrecognized option: replication.replSet"

The following manual correction in the YAML file  below allows mongod to start

replication:
replSetName: s0

 

https://www.mongodb.com/docs/manual/reference/configuration-options/#mongodb-setting-replication.replSetName

 

--outputConfig should output the correct name (replSetName) for use in the YAML file as it is different from the name that needs to be used as a command line option (replSet)

Sprint: Security 2022-12-12, Security 2022-12-26, Security 2023-01-09, Security 2023-01-23, Security 2023-02-06, Security 2023-05-01, Security 2023-05-15, Security 2023-06-12, Security 2023-07-24, Security 2023-08-07, Security 2023-08-21
Participants:

 Description   

Using "–outputConfig" to create a YAML configuration file produces an incorrect option name for the replica set name.  Tested in 5.0.5 but also seen in other versions of MongoDB (4.4.8) and likely many others.

 

 



 Comments   
Comment by Shreyas Kalyan [ 22/Aug/23 ]

We decided to not move forward with backporting these to prior server versions. If there is customer demand for this, please re-open the backport tickets.

Comment by Githook User [ 07/Aug/23 ]

Author:

{'name': 'Shreyas Kalyan', 'email': 'shreyas.kalyan@mongodb.com', 'username': 'shreyaskal'}

Message: SERVER-64852 mongod --outputConfig produces incorrect YAML option name (replSet vs. replSetName)
Branch: master
https://github.com/mongodb/mongo/commit/5478492ce37c8242dea50842bbc1aa623396b6e3

Comment by Sara Golemon [ 28/Mar/22 ]

Looks like both names are "valid" (for certain values of valid): https://github.com/mongodb/mongo/blob/dfc76374438cab06a7cce2a43280a7aa69432d78/src/mongo/db/mongod_options_replication.idl#L64-L76

The imbalance comes from one being valid for YAML configs (using full name), while the other is only valid in INI/CLI. This means that the fix here is non-trivial, our options are:

  1. Do not include non-YAML configs in --outputConfig output. This is suboptimal and confusing at best.
  2. Option 1, but also output CLI options, and probably also an INI section for settings that are INI only (do these exist?) Big disadvantage here is that you can't just cat the output of --outputConfig into a file and be gtg, it goes from machine readable to human readable only.
  3. Option2, but also exit non-zero to break existing uses in a predictable way. This has the disadvantage of preventing uses who expect combined outputs.
  4. Expand --outputConfig to take options, one or more of "yaml", "ini", "cli". As an advantage this lets us produce a fully-CLI version of the config using short names, which we can't do currently.
Comment by Edwin Zhou [ 24/Mar/22 ]

SERVER-36380 implements --outputConfig cc sara.golemon

Generated at Thu Feb 08 06:01:18 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.