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
     <snip>
  ------

  { 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 <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2024-03-22 13:24:01 +00:00
parent 4ad3b5695c
commit c20dd17088
1 changed files with 1 additions and 2 deletions

View File

@ -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."