The database image for MongoDB is not working

Created on 5 July 2024, 4 months ago

Problem/Motivation

The Gitlab CI pipeline for MongoDB resyult for every kernel and functionaltest with the same error: "MongoDB\Driver\Exception\ConnectionTimeoutException: No suitable servers found (`serverSelectionTryOnce` set)"

Steps to reproduce

See: https://git.drupalcode.org/issue/drupal-3403695/-/pipelines/215637

Proposed resolution

Fix the database container for MongoDB.

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Active

Component

Database Containers

Created by

🇳🇱Netherlands daffie

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @daffie
  • 🇳🇱Netherlands daffie

    My workflow:

    cd drupalci_environments/db/mongodb-7
    docker build --no-cache .
    # get the docker image
    docker image ls
    docker run -it df1bfbf41a98 bash
    # on the cli in the container run
    ./docker-entrypoint-initdb.d/startup.sh
    

    The last command will:
    - create the mongoDB instances;
    - create the replica set;
    - create the database user for Drupal.

    Hopefully this will make it easier for one of the maintainers to fix the problem.

    I have tried to create a MR, but I was not allowed to do so.

  • Status changed to Needs review 4 months ago
  • 🇳🇱Netherlands daffie

    Updated the IS and the patch.

  • First commit to issue fork.
  • 🇫🇷France andypost

    +1 to change CMD to ENTRYPOINT, sorry, I will check it later

  • 🇫🇷France andypost

    Btw, needs to check if gitlab-runner does no undet for entrypoint or cmd

  • 🇳🇱Netherlands bbrala Netherlands

    Few things to try.

    It seems it does at least try to connect? Locally i did have somme issues to connect normally with phpstorm, wonder if perhaps the auth database is wrong by default. Id i add the db used to db also it works a little easier, might be a thing.

    use db;
    db.createUser({
         user: rootUser,
         pwd: rootPassword,
         roles: [
           {role: "dbOwner", db: "admin"},
           {role: "dbOwner", db: "db"},
        ]
    });
    

    I'd (for testing purposed) output logging. Which would need 2 changes (stdout is hard with mutiple forks).

    
    mongod --dbpath /data/db1 --port 27017 --fork --logpath /var/log/mongodb/db1.log --replSet dbrs --keyFile /replica.key --bind_ip_all --transitionToAuth
    mongod --dbpath /data/db2 --port 27018 --fork --logpath /var/log/mongodb/db2.log --replSet dbrs --keyFile /replica.key --bind_ip_all --transitionToAuth
    mongod --dbpath /data/db3 --port 27019 --fork --logpath /var/log/mongodb/db3.log --replSet dbrs --keyFile /replica.key --bind_ip_all --transitionToAuth
    

    And then:

    tail -f /var/log/mongodb/db*.log
    

    ANyways, kinda hard to help and debug, my mongodb knowledge is kinda minimal. It does start and connect perfectly fine locally at least :x

  • 🇳🇱Netherlands bbrala Netherlands

    (commited changes to the issue fork)

  • 🇫🇷France andypost

    merged to simplify debug, new image rolled

  • Merge request !46Resolve #3459294 "Mongodb better readiness" → (Open) created by bbrala
  • 🇳🇱Netherlands bbrala Netherlands

    Seems tests are actually ran!

    See: https://git.drupalcode.org/project/drupal/-/merge_requests/7326/pipelines

    Currently using a different build see: https://git.drupalcode.org/project/drupal/-/merge_requests/7326/diffs?co...

    But seems the new changes are all good :)

  • 🇳🇱Netherlands bbrala Netherlands

    Updates the image last time, we do need the extra user

  • Merge request !50Draft: Resolve #3459294 "Mongodb" → (Open) created by bbrala
  • 🇳🇱Netherlands daffie

    @andypost: I am not allowed to create another branch on this issue. Therefore I have added a patch file. User @alcaeus works for MongoDB and he said that you can create a replica set with a single MongoDB instance. The added patch change the replica set to a single MongoDB instance. Could you give @alcaeus issue creates for his advice. I have been using this configuration for a week now and it is working fine.

Production build 0.71.5 2024