overleaf / toolkit

GNU Affero General Public License v3.0
510 stars 122 forks source link

Add support for Mongo 6.0 #261

Open mserranom opened 2 weeks ago

mserranom commented 2 weeks ago

Description

Adds support for Mongo 6.0 in preparation for the next minor release. The main changes are:

Upgrade instructions have been updated: https://github.com/overleaf/overleaf/wiki/Updating-Mongo-version/_compare/4e81c4348e2f8a30e2676af13ca7271493f53e75...acc881bbfc8f257d8d1b016e0ecbdd6cbc12b0ce

Test

With MONGO_IMAGE=mongo:5.0 in overleaf.rc:

# Image inspection
"Image": "mongo:5.0",
 "Healthcheck": {
            "Test": [
                "CMD-SHELL",
                "echo 'db.stats().ok' | mongo localhost:27017/test --quiet"
            ],
            "Interval": 10000000000,
            "Timeout": 10000000000,
            "Retries": 5
},
$ bin/mongo
MongoDB shell version v5.0.18
connecting to: mongodb://127.0.0.1:27017/sharelatex?compressors=disabled&gssapiServiceName=mongodb

Updated MONGO_IMAGE=mongo:6.0 in overleaf.rc (previously set feature compatibility to 5.0):

# Image inspection
 "Image": "mongo:6.0",
 "Healthcheck": {
            "Test": [
                "CMD-SHELL",
                "echo 'db.stats().ok' | mongosh localhost:27017/test --quiet"
            ],
            "Interval": 10000000000,
            "Timeout": 10000000000,
            "Retries": 5
        },
$ bin/mongo
Current Mongosh Log ID: 667032abd41272b4ef8db5fa
Connecting to:          mongodb://127.0.0.1:27017/sharelatex?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.2.6
Using MongoDB:          6.0.15
Using Mongosh:          2.2.6

In both versions: tested login, project creation and compiles.

Contributor Agreement

mserranom commented 2 weeks ago

GTM, not tested. There is a risk for these two to diverge now, e.g. the following is invalid but accepted by the Toolkit:

MONGO_VERSION=5.0.0
MONGO_IMAGE=my.registry.example.com/mongo:6.0.0

WDYT about adding MONGO_VERSION as tag to MONGO_IMAGE?

Been thinking about it:

I lean towards leaving it as it is. I've tweaked a little bit to make it fail when MONGO_VERSION is not defined (as you suggested), and updated the error message to make it clear MONGO_IMAGE need to be a valid version (<major>.<minor>).

Maybe @mlevans0 can weigh in?

mlevans0 commented 2 weeks ago

If I understand correctly, the MONGO_VERSION environment variable has been introduced to help identify which MongoDB shell to use (either mongo or mongosh). Other than that, its not used (still using MONGO_IMAGE in the compose file)?

The read_mongo_version function attempts to read MONGO_VERSION from config/overleaf.rc to set the correct MongoDB shell, but if MONGO_VERSION is not defined, it then tries to extract the version from MONGO_IMAGE instead and then issues a warning if it can't (in cases where it's a none-stock image).

Because of how this is handled, I think the MONGO_VERSION environment variable is unnecessary. Couldn't we parse the MONGO_IMAGE for the version number and show the warning if it's not a stock image (shortcutting the need for the variable)?

Adding MONGO_VERSION to the config/overleaf.rc file will be a manual step for existing deployments, and if missed, would result in it being undefined, and therefore falling back to the MONGO_IMAGE check anyway.

If we go with what's planned, and the MONGO_VERSION is only used for setting the MongoDB shell, this needs to be explicitly documented. It could cause some confusion when attempting upgrades - you only need to set MONGO_IMAGE and it must contain the version number - after MongoDB 6, you only need to set MONGO_IMAGE (with version number), MONGO_VERSION can be anything as long as its >= 6). It's also only really needed when going from 5 -> 6, after that there's no future requirement for it is there?