The database image for MongoDB does not create a replica set

Created on 5 July 2024, 2 months ago
Updated 3 August 2024, about 1 month ago

Problem/Motivation

The Gitlab CI pipeline for MongoDB result 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

How to test

From the root of the project drupalci_environments

// Apply the patch

// Goto the MongoDB image directory
cd db/mongodb-7

// Build the image.
docker build --no-cache .

// Get the image id for the newly build image.
docker image ls

// Get the image id and run the newly build container
docker run -it b753fd162e47 bash

The entrypoint script runs as the last command: rs.status();
The resulting replica set should have:
- the value of "set" (the replica set name) should be "dbrs";
- should have 3 members;
- and the option "ok" should be 1. The result should be something like:

{
  set: 'dbrs',
  date: ISODate('2024-07-31T16:29:36.252Z'),
  myState: 1,
  term: Long('1'),
  syncSourceHost: '',
  syncSourceId: -1,
  heartbeatIntervalMillis: Long('2000'),
  majorityVoteCount: 2,
  writeMajorityCount: 2,
  votingMembersCount: 3,
  writableVotingMembersCount: 2,
  optimes: {
    lastCommittedOpTime: { ts: Timestamp({ t: 1722443375, i: 1 }), t: Long('1') },
    lastCommittedWallTime: ISODate('2024-07-31T16:29:35.675Z'),
    readConcernMajorityOpTime: { ts: Timestamp({ t: 1722443375, i: 1 }), t: Long('1') },
    appliedOpTime: { ts: Timestamp({ t: 1722443375, i: 1 }), t: Long('1') },
    durableOpTime: { ts: Timestamp({ t: 1722443375, i: 1 }), t: Long('1') },
    lastAppliedWallTime: ISODate('2024-07-31T16:29:35.675Z'),
    lastDurableWallTime: ISODate('2024-07-31T16:29:35.675Z')
  },
  lastStableRecoveryTimestamp: Timestamp({ t: 1722443335, i: 1 }),
  electionCandidateMetrics: {
    lastElectionReason: 'electionTimeout',
    lastElectionDate: ISODate('2024-07-31T16:25:15.469Z'),
    electionTerm: Long('1'),
    lastCommittedOpTimeAtElection: { ts: Timestamp({ t: 1722443104, i: 1 }), t: Long('-1') },
    lastSeenOpTimeAtElection: { ts: Timestamp({ t: 1722443104, i: 1 }), t: Long('-1') },
    numVotesNeeded: 2,
    priorityAtElection: 2,
    electionTimeoutMillis: Long('10000'),
    numCatchUpOps: Long('0'),
    newTermStartDate: ISODate('2024-07-31T16:25:15.596Z'),
    wMajorityWriteAvailabilityDate: ISODate('2024-07-31T16:25:16.134Z')
  },
  members: [
    {
      _id: 1,
      name: 'localhost:27017',
      health: 1,
      state: 1,
      stateStr: 'PRIMARY',
      uptime: 275,
      optime: { ts: Timestamp({ t: 1722443375, i: 1 }), t: Long('1') },
      optimeDate: ISODate('2024-07-31T16:29:35.000Z'),
      lastAppliedWallTime: ISODate('2024-07-31T16:29:35.675Z'),
      lastDurableWallTime: ISODate('2024-07-31T16:29:35.675Z'),
      syncSourceHost: '',
      syncSourceId: -1,
      infoMessage: '',
      electionTime: Timestamp({ t: 1722443115, i: 1 }),
      electionDate: ISODate('2024-07-31T16:25:15.000Z'),
      configVersion: 1,
      configTerm: 1,
      self: true,
      lastHeartbeatMessage: ''
    },
    {
      _id: 2,
      name: 'localhost:27018',
      health: 1,
      state: 2,
      stateStr: 'SECONDARY',
      uptime: 271,
      optime: { ts: Timestamp({ t: 1722443365, i: 1 }), t: Long('1') },
      optimeDurable: { ts: Timestamp({ t: 1722443365, i: 1 }), t: Long('1') },
      optimeDate: ISODate('2024-07-31T16:29:25.000Z'),
      optimeDurableDate: ISODate('2024-07-31T16:29:25.000Z'),
      lastAppliedWallTime: ISODate('2024-07-31T16:29:35.675Z'),
      lastDurableWallTime: ISODate('2024-07-31T16:29:35.675Z'),
      lastHeartbeat: ISODate('2024-07-31T16:29:35.663Z'),
      lastHeartbeatRecv: ISODate('2024-07-31T16:29:34.686Z'),
      pingMs: Long('0'),
      lastHeartbeatMessage: '',
      syncSourceHost: 'localhost:27017',
      syncSourceId: 1,
      infoMessage: '',
      configVersion: 1,
      configTerm: 1
    },
    {
      _id: 3,
      name: 'localhost:27019',
      health: 1,
      state: 7,
      stateStr: 'ARBITER',
      uptime: 271,
      lastHeartbeat: ISODate('2024-07-31T16:29:35.640Z'),
      lastHeartbeatRecv: ISODate('2024-07-31T16:29:35.640Z'),
      pingMs: Long('0'),
      lastHeartbeatMessage: '',
      syncSourceHost: '',
      syncSourceId: -1,
      infoMessage: '',
      configVersion: 1,
      configTerm: 1
    }
  ],
  ok: 1,
  '$clusterTime': {
    clusterTime: Timestamp({ t: 1722443375, i: 1 }),
    signature: {
      hash: Binary.createFromBase64('AAAAAAAAAAAAAAAAAAAAAAAAAAA=', 0),
      keyId: Long('0')
    }
  },
  operationTime: Timestamp({ t: 1722443375, i: 1 })
}
🐛 Bug report
Status

Needs review

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

Production build 0.71.5 2024