helm-charts icon indicating copy to clipboard operation
helm-charts copied to clipboard

MongoDB auth error, internal and external mongo

Open codecex opened this issue 3 years ago • 4 comments

Im trying to deploy rocketchat using external mongodb, and im getting this error all the time, even if i use internal mongodb option:

`kc logs rocketchat-rocketchat-6b884967b4-h97pp -n rocketchat /app/bundle/programs/server/node_modules/fibers/future.js:313 throw(ex); ^

MongoError: Authentication failed. at MessageStream.messageHandler (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/connection.js:272:20) at MessageStream.emit (events.js:400:28) at processIncomingData (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/message_stream.js:144:12) at MessageStream.write (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/cmap/message_stream.js:42:5) at writeOrBuffer (internal/streams/writable.js:358:12) at MessageStream.Writable.write (internal/streams/writable.js:303:10) at Socket.ondata (internal/streams/readable.js:731:22) at Socket.emit (events.js:400:28) at addChunk (internal/streams/readable.js:293:12) at readableAddChunk (internal/streams/readable.js:267:9) at Socket.Readable.push (internal/streams/readable.js:206:10) at TCP.onStreamRead (internal/stream_base_commons.js:188:23) { operationTime: Timestamp { bsontype: 'Timestamp', low: 1, high: 1648539416 }, ok: 0, code: 18, codeName: 'AuthenticationFailed', '$clusterTime': { clusterTime: Timestamp { bsontype: 'Timestamp', low: 1, high_: 1648539416 }, signature: { hash: Binary { bsontype: 'Binary', sub_type: 0, position: 20, buffer: Buffer(20) [Uint8Array] [ 215, 121, 158, 104, 33, 118, 199, 10, 128, 84, 199, 167, 53, 69, 98, 19, 218, 86, 31, 49 ] }, keyId: Long { bsontype: 'Long', low: 2, high: 1648484028 } } } } `

My external mongodb is working propertly in the same k8s cluster & namespace in replicaset mode. Im using this 2 options in the values.yaml to connect to an external mongodb: (internal is set to false)

externalMongodbUrl: mongodb://rocketchat:[email protected]:27017/rocketchat externalMongodbOplogUrl: mongodb://root:[email protected]:27017/local?replicaSet=rs0&authSource=admin

What is wrong here?¿

Thanks in advance

codecex avatar Mar 29 '22 07:03 codecex

Does that issue still happens? It seems to be an environmental issue. What Kubernetes distribution are you using?

prppedro avatar Apr 25 '22 15:04 prppedro

still happening for me, the problem in my case is that i am trying to use an external secret to setup the internal DB and the pods fails to start because cant find the uri variables.

so i have included those but authentication fails. perhaps passwords should be b64 encoded in the uri ??

anyway some more doc on how the secret should like would be welcome

dberardo-com avatar Oct 26 '22 11:10 dberardo-com

I have the same issue on k3s and rocketchat-5.3.2.

kubectl version --short
Flag --short has been deprecated, and will be removed in the future. The --short output will become the default.
Client Version: v1.25.3
Kustomize Version: v4.5.7
Server Version: v1.25.2+k3s1

I run the helm chart like this:

helm install rocketchat rocketchat/rocketchat --set mongodb.auth.password="mongoauth",mongodb.auth.rootPassword="rootmongopassword"
helm list
NAME            NAMESPACE       REVISION        UPDATED                                 STATUS          CHART                   APP VERSION
rocketchat      default         1               2023-01-10 09:53:12.886609654 +0000 UTC deployed        rocketchat-5.3.2        5.3.2

Logs from the rocketchat pod:

/app/bundle/programs/server/node_modules/fibers/future.js:313                                            
                        throw(ex);                                                                       
                        ^                                                                                
                                                                                                         
MongoServerError: Authentication failed.                                                                 
    at MessageStream.messageHandler (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_m
    at MessageStream.emit (events.js:400:28)                                                             
    at processIncomingData (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mo
    at MessageStream._write (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/m
    at writeOrBuffer (internal/streams/writable.js:358:12)                                               
    at MessageStream.Writable.write (internal/streams/writable.js:303:10)                                
    at Socket.ondata (internal/streams/readable.js:731:22)                                               
    at Socket.emit (events.js:400:28)                                                                    
    at addChunk (internal/streams/readable.js:293:12)                                                    
    at readableAddChunk (internal/streams/readable.js:267:9)                                             
    at Socket.Readable.push (internal/streams/readable.js:206:10)                                        
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23) {                                       
  ok: 0,                                                                                                 
  code: 18,                                                                                              
  codeName: 'AuthenticationFailed',                                                                      
  '$clusterTime': {                                                                                      
    clusterTime: Timestamp { low: 1, high: 1673345675, unsigned: true },                                 
    signature: {                                                                                         
      hash: Binary {                                                                                     
        sub_type: 0,                                                                                     
        buffer: Buffer(20) [Uint8Array] [                                                                
          112, 104, 112,  16, 247,  60,                                                                  
          146, 115, 109, 254,  68, 109,                                                                  
           90, 141, 128,  23, 124, 111,                                                                  
          114, 181                                                                                       
        ],                                                                                               
        position: 20                                                                                     
      },                                                                                                 
      keyId: Long { low: 5, high: 1673343649, unsigned: false }                                          
    }                                                                                                    
  },                                                                                                     
  operationTime: Timestamp { low: 1, high: 1673345675, unsigned: true }                                  
}

nicop311 avatar Jan 10 '23 10:01 nicop311

You don't by chance happen to be deploying to a namespace called rocketchat?

I get the exact same error, but if I deploy to a namespace not called rocketchat but rc for example, my deployment succeeds. I'm using RKE2.

ghost avatar Feb 23 '23 19:02 ghost