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

[Bug]: MongoDB will not use all mongod.conf options when starting as shard config server #4406

Open
theDanielJLewis opened this issue Nov 26, 2024 · 2 comments
Labels
🐛 Bug Reported issues that need to be reproduced by the team. 🔍 Triage Issues that need assessment and prioritization.

Comments

@theDanielJLewis
Copy link

Error Message and Logs

BadValue: Cannot start a configsvr as a standalone server. Please use the option --replSet to start the node as a replica set.

Steps to Reproduce

  1. Create a MongoDB service (version 6, 7, or 8—it doesn't matter).
  2. Add the following configuration:
sharding:
  clusterRole: configsvr
replication:
  replSetName: "cfg0"
  1. Save and start the service.
  2. MongoDB will not start and will complain that the replica set option is missing, even though it's clearly there in the mongod.conf that Coolify creates.

Example Repository URL

No response

Coolify Version

v4.0.0-beta.370

Are you using Coolify Cloud?

No (self-hosted)

Operating System and Version (self-hosted)

Ubuntu 24.04

Additional Information

After a lot of digging and experimenting, I found the strangest cause for this. It's the command line of the docker-compose.yml file Coolify creates.

This is what Coolify's docker-compose.yml looks like (from /data/coolify/databases/xs40cogkgoosggg08ckkw44o/ matching the service name):

services:
    xs40cogkgoosggg08ckkw44o:
        image: 'mongo:8'
        command: '--config /etc/mongo/mongod.conf'
        container_name: xs40cogkgoosggg08ckkw44o
        # ...

But that doesn't work with a shard config server setup no matter what I do inside the conf file (manually or through Coolify).

However, if we replace the command line with:

 command: "/bin/sh -c 'exec mongod --config /etc/mongo/mongod.conf'"

Or:

entrypoint: "/bin/sh"
command: "-c 'exec mongod --config /etc/mongo/mongod.conf'"

And then start the process manually with docker compose up, then mongod appears to start fine.

This seems to be primarily a Docker problem, but it's a Coolify problem, too, because Coolify is creating this faulty docker-compose.yml file. And even though there's a way to adjust it to work, Coolify overwrites my changes every time I press "Start" in the Coolify dashboard.

Aside: even though the error message is complaining about missing replica set configuration, adding --replSet NAME to the command line still didn't fix it. It seems the only way to use Docker to start a shard config server is by doing the shell trick as shown above.

(I will report this in the issues for the Mongo docker image, too.)

@theDanielJLewis theDanielJLewis added 🐛 Bug Reported issues that need to be reproduced by the team. 🔍 Triage Issues that need assessment and prioritization. labels Nov 26, 2024
@theDanielJLewis theDanielJLewis changed the title [Bug]: [Bug]: MongoDB will not use all mongod.conf options when starting as shard config server Nov 26, 2024
@theDanielJLewis
Copy link
Author

@theDanielJLewis
Copy link
Author

It turns out this is a problem with the Docker image when passing username and password via environment variables. But this could be worked around if Coolify would let us modify the docker image command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Reported issues that need to be reproduced by the team. 🔍 Triage Issues that need assessment and prioritization.
Projects
None yet
Development

No branches or pull requests

1 participant