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

Added MONGO_REPLICASET for support to connect to existing replicaset #69

Closed
wants to merge 4 commits into from

Conversation

rundqvist
Copy link

linuxserver.io


  • I have read the contributing guideline and understand that I have made the correct modifications

Description:

Added new environment variable, MONGO_REPLICASET, that if set adds "replicaSet=[replicaset value]" to the connection string. It (if set) also reads the existing MONGO_HOST and MONGO_PORT as comma separated strings to be able to add all databases participating in the replicaset + checks that there are equal number of values in each variable.
Connection test on all nodes are performed.

Benefits of this PR and context:

If one has an existing replicaset it was not possible to add all hosts to the connection string via environment variables. You had to manually edit system.properties and add the compatible connection string.

How Has This Been Tested?

I have tested:

  • Connecting to a standalone instance
  • Connecting to a replicaset
  • Connecting to wrong ip/port (stops and cannot proceed as expected)
  • Restoring a .unf file to a replicaset

Developing/testing on a Mac running Ventura.

  • Visually confirmed that the "standalone" connection string was created as before.
  • Visually confirmed that the replicaset was generated as expected.
  • Tested replicaset connection against a raspberry pi-cluster with a three node Mongodb replicaset.

Source / References:

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for opening this pull request! Be sure to follow the pull request template!

@LinuxServer-CI
Copy link
Contributor

I am a bot, here is the pushed image/manifest for this PR:

ghcr.io/linuxserver/lspipepr-unifi-network-application:8.0.28-pkg-4aa034f5-dev-5a0ea67b812f449fdda9d8e962b6f7450aab3ea6-pr-69

@LinuxServer-CI
Copy link
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

@LinuxServer-CI
Copy link
Contributor

I am a bot, here is the pushed image/manifest for this PR:

ghcr.io/linuxserver/lspipepr-unifi-network-application:8.1.113-pkg-f2d4d5b2-dev-4d49e7a2d7005de9867d5f8a9a40c5eea3732a89-pr-69

@aptalca
Copy link
Member

aptalca commented Mar 23, 2024

Thanks for the PR, but I feel like this is such a niche case that it is best set up via editing the system.properties file. This is likely to confuse new users greatly and create a significant support burden for our team. Folks are already having a really hard time getting this up and running even with a single mongodb instance and with us providing the init script. We can't afford to complicate it any further.

That's just my opinion, though. I'll let the maintainer make the final decision.

@rundqvist
Copy link
Author

rundqvist commented Mar 27, 2024

@aptalca I am happy to contribute. And thank you for providing awesome containers.

I understand your concern, and I don't wish to increase the time you put on support.
But, since it works just as before if not configuring the replicaset, perhaps move the documentation of the feature to a separate section in the readme?
With a disclaimer "Unsupported feature (use only if you know what you are doing)" or something like that?

Just a suggestion. But I understand if you decide not to.

@LinuxServer-CI
Copy link
Contributor

I am a bot, here is the pushed image/manifest for this PR:

ghcr.io/linuxserver/lspipepr-unifi-network-application:8.1.113-pkg-6d1565cd-dev-57327750d2867900e56479f5f08481e915c59d06-pr-69

@LinuxServer-CI
Copy link
Contributor

I am a bot, here is the pushed image/manifest for this PR:

ghcr.io/linuxserver/lspipepr-unifi-network-application:8.1.113-pkg-5794ab45-dev-46d95dfeed8d25757d292145f853287cd7656916-pr-69

@11qu1d
Copy link

11qu1d commented May 11, 2024

I have had issues twice with mongodb getting corrupted due to ungraceful shutdown when running in standalone mode. A replica set would definitely help with such cases. Thankfully i had config backups and i was able to restore but definitely not a fun time... I would support this as a more robust solution, mongodb is not recommended to run in standalone configuration apart for development or testing as it is a single point of failure.

I understand that this would add complexity for novice users, but as @rundqvist mentioned it can be added as an optional or advanced feature.

@aptalca
Copy link
Member

aptalca commented May 11, 2024

If you want multiple mongodb instances, you can edit the system.properties file in your config folder.

The init we provide only works on first boot anyway. If one wants to change the mongodb details later (password, address, etc), they have to edit the system.properties file.

There is very little benefit in having our first time only init support a replica setup. But there are huge risks: 1. Code is much more complicated with a larger potential for bugs, 2. Promoting that to a general audience is a support nightmare.
Our general users are already having a hard enough time setting up a single instance with the preset init-mongo.js we provide, if you look through our github, forum and discord threads.

@aptalca aptalca closed this May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants