linuxserver / docker-unifi-network-application

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

[FEAT] Offer FerretDB as an alternative to MongoDB #56

Closed stevekerrison closed 4 months ago

stevekerrison commented 5 months ago

Is this a new feature request?

Wanted change

To de-couple the Unifi Controller from its dependency on MongoDB 4.x, provide a configuration that supports FerretDB, which is protocol-compatible with MongoDB clients, but implements the database as either SQLite or PoestgreSQL.

Reason for change

This removes a dependency on a version of Mongo that will not be supported much longer (Feb 2024 for MongoDB 4.4). Newer versions are not officially supported by Ubiquity, and it's possible they never will be due to licensing changes. Additionally, newer Mongo versions require CPU instruction extensions not present on some devices (Raspberry Pi, Atom/Celeron) that may be in use by users of this container. Building a version of Mongo without this requirement is possible, but the licensing disparity remains.

FerretDB would allow use of the established architecture to continue without the above issues, provided it can provide feature-equivalence for the unifi controller client and suitable performance.

It's not clear what approach Ubiquity will take to solve this issue, if any, so this is an attempt to solve this issue regardless of what they may or may not release in the future.

Proposed code change

Introduce configuration options and examples for using a FerretDB backend instead of MongoDB, and do testing to ensure reliability and indicate performance expectations.

I have started this myself with an experimental fork of this project, but wish to seek input via a feature issue before crafting a branch suitable for a PR. My changes are not yet aligned with the PR requirements, but you can compare to see the fundamental changes which are mainly in environment variable handling.

So far I have successfully instantiated a controller against SQLite and PostgreSQL backends with FerretDB, and restored backup configuration and telemetry into said backends and verified operation through the unifi dashboard. However, I have not yet switched over control of my APs to any of these instantiations, and I have noted that performance with SQLite may be problematic.

github-actions[bot] commented 5 months ago

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

drizuid commented 4 months ago

Users are welcome to use whatever they like, that is why we split mongo out from unifi in the first place. However, we will not modify the readme to encompass this as we do not wish to carry the support burden. Internally we've tested all versions of mongo and that is what we'll support. If users wish to use other things, they are more than welcome to as long as they support themselves.

As a side note, thank you for the well written and detailed posting, I'm going to lock this, but not close it yet, because I'd like the team to internally discuss pinning this. Although we won't support it, for users with no avx that want a non-eol mongo (but dont care about ubnt's support stance) this is good guidance.

drizuid commented 4 months ago

NOTE, this is not a setup endorsed or supported by linuxserver.io, however, the information is considered valuable enough for certain user bases that we are pinning this.