From c20dd170883b378de4d3404b90ae8ab11b253490 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Fri, 22 Mar 2024 13:24:01 +0000 Subject: [PATCH] devstack: Fix version check mongosh versions 2.2.0 appears to have changed the verbosity of logging. We are attempting to extract version information from the output, but looking at it manually shows no such output. $ mongosh zaqar --eval 'db.dropDatabase();' { ok: 1, dropped: 'zaqar' } Downgrading the package to the last release before 2.2.0, 2.1.5, reveals what we had been expecting: $ sudo apt install mongodb-mongosh=2.1.5 $ mongosh zaqar --eval 'db.dropDatabase();' Current Mongosh Log ID: 65fd88a57854a39dcce03169 Connecting to: mongodb://127.0.0.1:27017/zaqar?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.1.5 Using MongoDB: 7.0.7 Using Mongosh: 2.1.5 For mongosh info see: https://docs.mongodb.com/mongodb-shell/ To help improve our products, anonymous usage data is collected and sent to MongoDB periodically (https://www.mongodb.com/legal/privacy-policy). You can opt-out by running the disableTelemetry() command. ------ The server generated these startup warnings when booting ------ { ok: 1, dropped: 'zaqar' } We *could* increase the verbosity again using the '--verbosity' flag, but rather than relying on arbitrary logging output, we could just use the 'db.version()' function to pull our server version. Use that instead. Change-Id: I1faa317ebfa9927a4d576bd4da72872fab160560 Signed-off-by: Stephen Finucane --- devstack/plugin.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 24b8d3715..9bc2bbfc9 100755 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -55,8 +55,7 @@ function cleanup_zaqar_mongodb { if ! timeout $SERVICE_TIMEOUT sh -c "while ! mongosh zaqar --eval 'db.dropDatabase();'; do sleep 1; done"; then die $LINENO "Mongo DB did not start" else - full_version=$(mongosh zaqar --eval 'db.dropDatabase();') - mongo_version=`echo $full_version | cut -d' ' -f11` + mongo_version=$(mongosh zaqar --eval 'db.version();') required_mongo_version='6.0' if [[ $mongo_version < $required_mongo_version ]]; then die $LINENO "Zaqar needs Mongo DB version >= 6.0 to run."