cvallance / mongo-k8s-sidecar

Kubernetes sidecar for Mongo
MIT License
440 stars 298 forks source link

Error in workloop { MongoError: Unsupported OP_QUERY command: replSetGetStatus. The client driver may require an upgrade. #132

Open antoniantonov opened 1 year ago

antoniantonov commented 1 year ago

Running mongo-k8s-sidecar in AKS attempting to initialize 3 replica statefulset MongoDB. I'm getting this error:

Error in workloop { MongoError: Unsupported OP_QUERY command: replSetGetStatus. The client driver may require an upgrade. For more details see https://dochub.mongodb.org/core/legacy-opcode-removal
    at Function.MongoError.create (/opt/cvallance/mongo-k8s-sidecar/node_modules/mongodb-core/lib/error.js:31:11)
    at /opt/cvallance/mongo-k8s-sidecar/node_modules/mongodb-core/lib/connection/pool.js:497:72
    at authenticateStragglers (/opt/cvallance/mongo-k8s-sidecar/node_modules/mongodb-core/lib/connection/pool.js:443:16)
    at Connection.messageHandler (/opt/cvallance/mongo-k8s-sidecar/node_modules/mongodb-core/lib/connection/pool.js:477:5)
    at Socket.<anonymous> (/opt/cvallance/mongo-k8s-sidecar/node_modules/mongodb-core/lib/connection/connection.js:333:22)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:287:12)
    at readableAddChunk (_stream_readable.js:268:11)
    at Socket.Readable.push (_stream_readable.js:223:10)
    at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:122:17)
  name: 'MongoError',
  message:
   'Unsupported OP_QUERY command: replSetGetStatus. The client driver may require an upgrade. For more details see https://dochub.mongodb.org/core/legacy-opcode-removal',
  ok: 0,
  errmsg:
   'Unsupported OP_QUERY command: replSetGetStatus. The client driver may require an upgrade. For more details see https://dochub.mongodb.org/core/legacy-opcode-removal',
  code: 352,
  codeName: 'UnsupportedOpQueryCommand',
  '$clusterTime':
   { clusterTime:
      Timestamp { _bsontype: 'Timestamp', low_: 1, high_: 1679318758 },
     signature:
      { hash:
         Binary {
           _bsontype: 'Binary',
           sub_type: 0,
           position: 20,
           buffer:
            <Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00> },
        keyId: 0 } },
  operationTime:
   Timestamp { _bsontype: 'Timestamp', low_: 1, high_: 1679318758 } }

Here's my StatefulSet yaml:

apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: mongodb
spec:
  serviceName: "mongodb"
  replicas: 3
  selector:
    matchLabels:
      app: mongodb
  template:
    metadata:
      labels:
        app: mongodb
    spec:
      containers:
      - name: mongodb
        image: mongo:latest
        command: ["mongod"]
        args:
          - --bind_ip_all
          - --replSet
          - rs0
        ports:
        - containerPort: 27017
        volumeMounts:
        - name: mongo-data
          mountPath: /data/db
      - name: mongodb-sidecar
        image: cvallance/mongo-k8s-sidecar:latest
        env:
          - name: MONGO_SIDECAR_POD_LABELS
            value: "app=mongodb"
          - name: KUBERNETES_MONGO_SERVICE_NAME
            value: mongodb
  volumeClaimTemplates:
  - metadata:
      name: mongo-data
    spec:
      accessModes:
        - ReadWriteOnce
      resources:
        requests:
          storage: 20Gi
---
apiVersion: v1
kind: Service
metadata:
  name: mongodb
spec:
  selector:
    app: mongodb
  ports:
    - protocol: TCP
      port: 27017
      targetPort: 27017
  clusterIP: None
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: default-view
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: view
subjects:
  - kind: ServiceAccount
    name: default
    namespace: default

Workaround: Using mongo:5.0.15 for the primary container image resolves the issue.

Suggestion: Not sure but it seems upgrading the client driver might be required.

aboutdever commented 2 weeks ago

I have the same problem.

Not working on docker.io/library/mongo:latest

Not working on docker.io/mongodb/mongodb-community-server:latest