Bug 279029 - net-mgmt/unifi8: switch MongoDB dependency from 5.0 to 6.0
Summary: net-mgmt/unifi8: switch MongoDB dependency from 5.0 to 6.0
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Juraj Lutter
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-05-16 11:33 UTC by Ronald Klop
Modified: 2024-08-20 07:08 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (otis)


Attachments
git diff: update mongodb dependency (1.84 KB, text/plain)
2024-05-16 11:33 UTC, Ronald Klop
no flags Details
git diff: update mongodb dependency (2.06 KB, patch)
2024-05-22 15:21 UTC, Ronald Klop
ronald: maintainer-approval?
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ronald Klop freebsd_committer freebsd_triage 2024-05-16 11:33:15 UTC
Created attachment 250696 [details]
git diff: update mongodb dependency

In October 2024 MongoDB 5.0 goes EOL.
Lets have the Unifi port in a good shape in time for this.

The patch updates the dependency.
Plus it changes PORTVERSION to DISTVERSION as advised in the porters handbook.
Comment 1 mca_two 2024-05-21 12:02:38 UTC
If I understood correctly, unifi8.1 and upwards only support MongoDB 7.0 (and 3.6, 4.4) but no 5.x or 6.x


>> *  UniFi Network Application 7.5 and newer requires MongoDB 3.6 and Java 17.
>> *  Version 7.5 till 8.0 supports up to MongoDB 4.4.
>> *  Version 8.1 and newer supports up to MongoDB 7.0.
>> Does that imply >8.1 supports all versions between 3.6 and 7.0? Or only 3.6, 4.4
>> and 7.0? So no 5.x or 6.x?

> .From UI release notes on mongodb, that is what I believe. "Or only 3.6, 4.4 and
> 7.0? So no 5.x or 6.x?" Plus there has not been anything specific 5.X or 6.X in
> any release notes going way back. Plus it is only on the self-hosted (Linux)
> installs, others have been asking about Windows updating to mongodb 7.X, nothing
> mentioned about MacOS either. Console devices are still on 3.6 or 4.4.
Comment 2 Ronald Klop freebsd_committer freebsd_triage 2024-05-21 13:12:56 UTC
(In reply to mca_two from comment #1)
I don't think you understood correctly.
To me "up to MongoDB 7.0" implies it supports all versions between and including 3.6 and 7.0.
Comment 3 mca_two 2024-05-21 13:49:40 UTC
(In reply to Ronald Klop from comment #2)

> To me "up to MongoDB 7.0" implies
That's indeed the issue, the changelogs aren't crystal clear. Maybe it's a problem on my end, but the issue below made me believe unifi8 doesn't work with mongoDB 5.0 (and 6.0)
https://forums.FreeBSD.org/threads/unifi-controller-works-fine-but-mongo-keeps-crashing-in-jail.93088/
Comment 4 Ronald Klop freebsd_committer freebsd_triage 2024-05-21 15:23:05 UTC
(In reply to mca_two from comment #3)
That MongoDB 5.0 crash had to do with the non-AVX CPU.
See: https://www.freshports.org/databases/mongodb50/#history

It had nothing to do with the question if Unifi 8.1 can run using MongoDB 5.0.
Comment 5 Ronald Klop freebsd_committer freebsd_triage 2024-05-22 11:29:12 UTC
While testing this in runtime I found an issue.

My MongoDB is running 5.0 but it was still configured with featureCompatibilityVersion=4.4 which does not work when running 6.0.

{"t":{"$date":"2024-05-22T10:36:42.574+02:00"},"s":"F",  "c":"CONTROL",  "id":20573,   "ctx":"initandlisten","msg":"Wrong mongod version","attr":{"error":"UPGRADE PROBLEM: Found an invalid featureCompatibilityVersion document (ERROR: Location4926900: Invalid featureCompatibilityVersion document in admin.system.version: { _id: \"featureCompatibilityVersion\", version: \"4.4\" }. See https://docs.mongodb.com/master/release-notes/5.0-compatibility/#feature-compatibility. :: caused by :: Invalid feature compatibility version value, expected '5.0' or '5.3' or '6.0. See https://docs.mongodb.com/master/release-notes/5.0-compatibility/#feature-compatibility.). If the current featureCompatibilityVersion is below 5.0, see the documentation on upgrading at https://docs.mongodb.com/master/release-notes/5.0/#upgrade-procedures."}}

I think this needs some more documentation somewhere.

https://www.mongodb.com/docs/v6.0/release-notes/6.0-upgrade-standalone/

On a running Unifi instance run:
# mongo --port 27117
MongoDB shell version v5.0.26
connecting to: mongodb://127.0.0.1:27117/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("5a997bc5-667f-4f96-954b-84ca929d3a6c") }
MongoDB server version: 5.0.26
================
Warning: the "mongo" shell has been superseded by "mongosh",
which delivers improved usability and compatibility.The "mongo" shell has been deprecated and will be removed in
an upcoming release.
For installation instructions, see
https://docs.mongodb.com/mongodb-shell/install/
================
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
	https://docs.mongodb.com/
Questions? Try the MongoDB Developer Community Forums
	https://community.mongodb.com
---
The server generated these startup warnings when booting: 
        2024-05-22T10:49:54.474+02:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
        2024-05-22T10:49:54.475+02:00: Soft rlimits for open file descriptors too low
        2024-05-22T10:49:54.475+02:00:         currentValue: 26676
        2024-05-22T10:49:54.475+02:00:         recommendedMinimum: 64000
---
> db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } )
{ "featureCompatibilityVersion" : { "version" : "4.4" }, "ok" : 1 }
> db.adminCommand( { setFeatureCompatibilityVersion: "5.0" } )
{ "ok" : 1 }
> exit
bye


This works.
Just a dump of my progress. Have to do some $work now.
Comment 6 Ronald Klop freebsd_committer freebsd_triage 2024-05-22 15:21:00 UTC
Created attachment 250874 [details]
git diff: update mongodb dependency

Updated the UPDATING entry with a remark about featureCompatibilityVersion.

Unifi8 is now running on MongoDB 6 at my home using an in-place upgrade of mongodb.
Comment 7 commit-hook freebsd_committer freebsd_triage 2024-06-06 05:02:07 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=33c9c139acad33ccd35f28dbc7f585cc353302e4

commit 33c9c139acad33ccd35f28dbc7f585cc353302e4
Author:     Juraj Lutter <otis@FreeBSD.org>
AuthorDate: 2024-06-06 04:55:11 +0000
Commit:     Juraj Lutter <otis@FreeBSD.org>
CommitDate: 2024-06-06 04:59:45 +0000

    net-mgmt/unifi8: Update to 8.2.93

    - Update to 8.2.93
    - Switch to MongoDB 6.0 (see UPDATING entry) [1]

    PR:             279029 [1]

 UPDATING                 | 15 +++++++++++++++
 net-mgmt/unifi8/Makefile |  4 ++--
 net-mgmt/unifi8/distinfo | 10 +++++-----
 3 files changed, 22 insertions(+), 7 deletions(-)
Comment 8 Ronald Klop freebsd_committer freebsd_triage 2024-06-18 14:34:54 UTC
Thanks for your work on this port. 🏆
Comment 9 Juraj Lutter freebsd_committer freebsd_triage 2024-06-18 15:42:53 UTC
While we are here, could you please rephrase the UPDATING entry to be more specific, in terms of when to run db.adminCommand, how to connect to the mongodb instnace and similar?

Thanks.
Comment 10 Emanuele 2024-06-24 09:34:45 UTC
Hello, how am I supposed to fix the issue if I didn't change the string on the database before restarting the unifi service? My mongodb service doesn't start anymore due to this limitation.

Thank you!
Comment 11 Ronald Klop freebsd_committer freebsd_triage 2024-06-24 10:04:27 UTC
(In reply to Emanuele from comment #10)
Just install mongodb50 again and it starts. It didn't migrate any tables yet.

Mongodb50 contains a 'mongo' CLI shell program.
On the machine or jail running mongod run the following command to connect to the Mongo DB.
$ mongo --port 27117

After setting the right featureCompatibilityVersion you can install mongodb60 again.
Comment 12 Juraj Lutter freebsd_committer freebsd_triage 2024-06-24 10:08:10 UTC
The other option is (provided that you have the backup .unf files) to save the backup files to a safe location, delete the database and start with clean installation, restoring the instance from .unf files.
Comment 13 Emanuele 2024-06-24 12:44:12 UTC
(In reply to Juraj Lutter from comment #12)
I have an updated unf backup file (from a daily auto-backup) so I tried to create a new jail (13.3-RELEASE-p3) from scratch and install unifi8 (unifi8-8.2.93) but it fails to start and no logs are created within /usr/local/share/java/unifi/logs.
Comment 14 Emanuele 2024-06-24 15:26:47 UTC
(In reply to Emanuele from comment #13)
I tried to create a new 13.3-RELEASE-p3 jail (once again) but tried installing unifi8-8.1.113 which requires (and installs) mongodb50-5.0.26_2 but I don't know why the UniFi service is unable to start and I can't find any reason/log under /var/log.

No file gets created on /usr/local/share/java/unifi/data/ and /usr/local/share/java/unifi/logs/

It seems like if a fresh new install of unifi8 doesn't work anymore (but can't tell why).

I don't know if I can do something more in order to debug it :-S
Comment 15 Ronald Klop freebsd_committer freebsd_triage 2024-06-25 13:00:22 UTC
(In reply to Juraj Lutter from comment #9)
What do you think about this change to UPDATING?

diff --git a/UPDATING b/UPDATING
index cd95246f6aa0..80a98a7dd50f 100644
--- a/UPDATING
+++ b/UPDATING
@@ -55,6 +55,10 @@ you update your ports collection, before attempting any port upgrades.
   For an in-place upgrade it is important that the MongoDB
   'featureCompatibilityVersion' is set to 5.0.
   See: https://www.mongodb.com/docs/v6.0/release-notes/6.0-upgrade-standalone/#feature-compatibility-version
+  Run these commands in mongodb50 before upgrading:
+  $ mongo --port 27117
+  > db.adminCommand( { setFeatureCompatibilityVersion: "5.0" } )
+  > exit
 
   See updating entry 20230310 for a backup/restore upgrade.
Comment 16 Juraj Lutter freebsd_committer freebsd_triage 2024-06-30 07:58:56 UTC
(In reply to Ronald Klop from comment #15)
Yes, please go ahead.
Comment 17 commit-hook freebsd_committer freebsd_triage 2024-07-01 17:18:24 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=5ac0b01d93bc16fbcaa136aacacf1fb50ea1f9a5

commit 5ac0b01d93bc16fbcaa136aacacf1fb50ea1f9a5
Author:     Ronald Klop <ronald@FreeBSD.org>
AuthorDate: 2024-06-25 19:07:40 +0000
Commit:     Ronald Klop <ronald@FreeBSD.org>
CommitDate: 2024-07-01 17:17:40 +0000

    UPDATING: clarify unifi8 + mongodb60 in place upgrade

    PR:     279029

 UPDATING | 4 ++++
 1 file changed, 4 insertions(+)
Comment 18 Ryan 2024-08-18 20:37:24 UTC
(In reply to Emanuele from comment #14)

Did you ever figure out a solution to this issue? Im seeing the same behavior, unifi8 fails in a brand new jail
Comment 19 Ronald Klop freebsd_committer freebsd_triage 2024-08-20 07:06:33 UTC
(In reply to Ryan from comment #18)
Does your jail have allow.mlock enabled?

NB: if this suggestion does help, are you able to open a new PR issue for this?
Comment 20 Ronald Klop freebsd_committer freebsd_triage 2024-08-20 07:08:40 UTC
(In reply to Ronald Klop from comment #19)
Mmm, I meant “… does NOT help …”