linuxserver / docker-unifi-network-application

GNU General Public License v3.0
551 stars 40 forks source link

Added MONGO_REPLICASET for support to connect to existing replicaset #69

Closed rundqvist closed 1 month ago

rundqvist commented 4 months ago

linuxserver.io



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:

Developing/testing on a Mac running Ventura.

Source / References:

LinuxServer-CI commented 4 months ago

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 commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

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 commented 3 months ago

@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 commented 2 months ago

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 commented 2 months ago

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 commented 1 month ago

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 commented 1 month ago

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.