Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-72817

On initial run mongod ignores replSet option set in cli

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Replication
    • None
    • Environment:
      kubernetes cluster (k3s) installed in AWS ec2
      image: mongo:4.4.4-bionic
    • ALL

      TL DR
      mongod --wiredTigerCacheSizeGB 0.25 --replSet rs0 --keyFile /data/db/security.keyFile ignored replSet param on initial run (means there no /data/db folder yet) in docker container, as running in js script rs.initiate() command showing following non-fatal error in mongod logs
      ```
      MongoDB server version: 4.4.4

      {     "ok" : 0,     "errmsg" : "This node was not started with the replSet option",     "code" : 76,     "codeName" : "NoReplicationEnabled" }

      ```
      Also mongod logs showing following for cli params passed
      ```
      Options set by command line","attr":{"options":{"net":{"bindIp":"127.0.0.1","port":27017,"tls":{"mode":"disabled"}},"processManagement":{"fork":true,"pidFilePath":"/tmp/docker-entrypoint-temp-mongod.pid"},"security":{"keyFile":"/data/db/security.keyFile"},"storage":{"wiredTiger":{"engineConfig":

      {"cacheSizeGB":0.25}

      }},"systemLog":{"destination":"file","logAppend":true,"path":"/proc/1/fd/1"}}}}
      ```

      Using following manifests:
      ```
      apiVersion: v1
      kind: Service
      metadata:
        name: mongo
        labels:
          app: mongo
      spec:
        ports:
        - port: 27017
        selector:
          app: mongo

      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: mongo
        namespace: default
      spec:
        replicas: 1
        revisionHistoryLimit: 1
        strategy:
          type: Recreate
        selector:
          matchLabels:
            app: mongo
        template:
          metadata:
            labels:
              app: mongo
              tier: base
          spec:
            hostNetwork: true
            dnsPolicy: ClusterFirstWithHostNet
            containers:
            - name: mongo
              image: mongo:4.4.4-bionic
              args:
                - "--wiredTigerCacheSizeGB"
                - "0.25"
                - "--replSet"
                - "rs0"
                - "--keyFile"
                - "/data/db/security.keyFile"
              ports:
              - containerPort: 27017
              volumeMounts:
              - name: data
                mountPath: /data/db
              - name: entrypoint
                mountPath: /docker-entrypoint-initdb.d/
              env:
                - name: MONGO_INITDB_DATABASE
                  valueFrom:
                    configMapKeyRef:
                      key: MONGO_DB
                      name: envars
                - name: MONGO_INITDB_ROOT_USERNAME
                  valueFrom:
                    secretKeyRef:
                      key: MONGO_USER
                      name: sealed-secrets
                - name: MONGO_INITDB_ROOT_PASSWORD
                  valueFrom:
                    secretKeyRef:
                      key: MONGO_PASS
                      name: sealed-secrets
            volumes:
            - name: data
              hostPath:
                path: /data/mongodata
                type: DirectoryOrCreate
            - name: entrypoint
              secret:
                secretName: mongo-init
      ```
      mongo-init secret value is
      #/bin/bash

      sleep 10s
      mongo -u ${MONGO_INITDB_ROOT_USERNAME} -p ${MONGO_INITDB_ROOT_PASSWORD} <<EOF
      rs.initiate()
      EOF

      sleep 10s

            Assignee:
            chris.kelly@mongodb.com Chris Kelly
            Reporter:
            ivan.c@taskworld.com Ivan Cherviakov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: