Skip to content
This repository was archived by the owner on Mar 16, 2024. It is now read-only.
This repository was archived by the owner on Mar 16, 2024. It is now read-only.

When a new DB is created in an existing cluster with same username (from existing DB) , consuming app is not able to connect to the DB. #9

Open
@sangee2004

Description

@sangee2004

Steps to reproduce the problem:

  1. Deploy mongodb-atlas service - app1
    acorn run -n app1 . --clusterName santest1 --dbName test1 --dbUser testusernew --provider AWS --region US_WEST_2
  2. Deploy consuming app - consumingapp1 for app1 . Make sure consuming app is able to connect successfully to DB.
  3. Deploy another mongodb-atlas service - app2 using the same clusterName and dbUser but different dbName
    acorn run -n app2 . --clusterName santest1 --dbName test3 --dbUser testusernew --provider AWS --region US_WEST_2
  4. Deploy consuming app - consumingapp2 for app2 . Make sure consuming app is able to connect successfully to DB.
    After this,

Try to make a DB connection from consumingapp1 (from step2). DB connection starts failing:

app-59f4c69fff-4n2jr: INFO:     10.42.15.197:45666 - "GET / HTTP/1.1" 200 OK
app-59f4c69fff-4n2jr: INFO:     10.42.15.197:45666 - "GET / HTTP/1.1" 200 OK
app-59f4c69fff-4n2jr: INFO:     10.42.15.197:41122 - "GET / HTTP/1.1" 200 OK
app-59f4c69fff-4n2jr: INFO:     10.42.15.197:48266 - "GET / HTTP/1.1" 200 OK
app-59f4c69fff-4n2jr: INFO:     10.42.15.197:36614 - "GET / HTTP/1.1" 500 Internal Server Error
app-59f4c69fff-4n2jr: ERROR:    Exception in ASGI application
app-59f4c69fff-4n2jr: Traceback (most recent call last):
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi
app-59f4c69fff-4n2jr:     result = await app(  # type: ignore[func-returns-value]
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
app-59f4c69fff-4n2jr:     return await self.app(scope, receive, send)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/fastapi/applications.py", line 289, in __call__
app-59f4c69fff-4n2jr:     await super().__call__(scope, receive, send)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/starlette/applications.py", line 122, in __call__
app-59f4c69fff-4n2jr:     await self.middleware_stack(scope, receive, send)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 184, in __call__
app-59f4c69fff-4n2jr:     raise exc
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 162, in __call__
app-59f4c69fff-4n2jr:     await self.app(scope, receive, _send)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
app-59f4c69fff-4n2jr:     raise exc
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
app-59f4c69fff-4n2jr:     await self.app(scope, receive, sender)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
app-59f4c69fff-4n2jr:     raise e
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
app-59f4c69fff-4n2jr:     await self.app(scope, receive, send)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 718, in __call__
app-59f4c69fff-4n2jr:     await route.handle(scope, receive, send)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 276, in handle
app-59f4c69fff-4n2jr:     await self.app(scope, receive, send)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 66, in app
app-59f4c69fff-4n2jr:     response = await func(request)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 273, in app
app-59f4c69fff-4n2jr:     raw_response = await run_endpoint_function(
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 190, in run_endpoint_function
app-59f4c69fff-4n2jr:     return await dependant.call(**values)
app-59f4c69fff-4n2jr:   File "/app/main.py", line 32, in hello
app-59f4c69fff-4n2jr:     counter_data = collection.find_one({"_id": "page_counter"})
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/pymongo/collection.py", line 1328, in find_one
app-59f4c69fff-4n2jr:     for result in cursor.limit(-1):
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/pymongo/cursor.py", line 1238, in next
app-59f4c69fff-4n2jr:     if len(self.__data) or self._refresh():
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/pymongo/cursor.py", line 1155, in _refresh
app-59f4c69fff-4n2jr:     self.__send_message(q)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/pymongo/cursor.py", line 1044, in __send_message
app-59f4c69fff-4n2jr:     response = client._run_operation(
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/pymongo/mongo_client.py", line 1424, in _run_operation
app-59f4c69fff-4n2jr:     return self._retryable_read(
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/pymongo/mongo_client.py", line 1525, in _retryable_read
app-59f4c69fff-4n2jr:     return func(session, server, sock_info, secondary_ok)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/pymongo/mongo_client.py", line 1420, in _cmd
app-59f4c69fff-4n2jr:     return server.run_operation(
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/pymongo/server.py", line 130, in run_operation
app-59f4c69fff-4n2jr:     _check_command_response(first, sock_info.max_wire_version)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/pymongo/helpers.py", line 167, in _check_command_response
app-59f4c69fff-4n2jr:     raise OperationFailure(errmsg, code, response, max_wire_version)
app-59f4c69fff-4n2jr: pymongo.errors.OperationFailure: user is not allowed to do action [find] on [test1.hits_collection], full error: {'ok': 0, 'errmsg': 'user is not allowed to do action [find] on [test1.hits_collection]', 'code': 8000, 'codeName': 'AtlasError'}
app-59f4c69fff-4n2jr: INFO:     10.42.15.197:53056 - "GET / HTTP/1.1" 500 Internal Server Error
app-59f4c69fff-4n2jr: ERROR:    Exception in ASGI application
app-59f4c69fff-4n2jr: Traceback (most recent call last):
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi
app-59f4c69fff-4n2jr:     result = await app(  # type: ignore[func-returns-value]
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
app-59f4c69fff-4n2jr:     return await self.app(scope, receive, send)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/fastapi/applications.py", line 289, in __call__
app-59f4c69fff-4n2jr:     await super().__call__(scope, receive, send)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/starlette/applications.py", line 122, in __call__
app-59f4c69fff-4n2jr:     await self.middleware_stack(scope, receive, send)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 184, in __call__
app-59f4c69fff-4n2jr:     raise exc
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 162, in __call__
app-59f4c69fff-4n2jr:     await self.app(scope, receive, _send)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
app-59f4c69fff-4n2jr:     raise exc
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
app-59f4c69fff-4n2jr:     await self.app(scope, receive, sender)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
app-59f4c69fff-4n2jr:     raise e
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
app-59f4c69fff-4n2jr:     await self.app(scope, receive, send)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 718, in __call__
app-59f4c69fff-4n2jr:     await route.handle(scope, receive, send)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 276, in handle
app-59f4c69fff-4n2jr:     await self.app(scope, receive, send)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 66, in app
app-59f4c69fff-4n2jr:     response = await func(request)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 273, in app
app-59f4c69fff-4n2jr:     raw_response = await run_endpoint_function(
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/fastapi/routing.py", line 190, in run_endpoint_function
app-59f4c69fff-4n2jr:     return await dependant.call(**values)
app-59f4c69fff-4n2jr:   File "/app/main.py", line 32, in hello
app-59f4c69fff-4n2jr:     counter_data = collection.find_one({"_id": "page_counter"})
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/pymongo/collection.py", line 1328, in find_one
app-59f4c69fff-4n2jr:     for result in cursor.limit(-1):
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/pymongo/cursor.py", line 1238, in next
app-59f4c69fff-4n2jr:     if len(self.__data) or self._refresh():
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/pymongo/cursor.py", line 1155, in _refresh
app-59f4c69fff-4n2jr:     self.__send_message(q)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/pymongo/cursor.py", line 1044, in __send_message
app-59f4c69fff-4n2jr:     response = client._run_operation(
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/pymongo/mongo_client.py", line 1424, in _run_operation
app-59f4c69fff-4n2jr:     return self._retryable_read(
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/pymongo/mongo_client.py", line 1525, in _retryable_read
app-59f4c69fff-4n2jr:     return func(session, server, sock_info, secondary_ok)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/pymongo/mongo_client.py", line 1420, in _cmd
app-59f4c69fff-4n2jr:     return server.run_operation(
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/pymongo/server.py", line 130, in run_operation
app-59f4c69fff-4n2jr:     _check_command_response(first, sock_info.max_wire_version)
app-59f4c69fff-4n2jr:   File "/usr/local/lib/python3.9/site-packages/pymongo/helpers.py", line 167, in _check_command_response
app-59f4c69fff-4n2jr:     raise OperationFailure(errmsg, code, response, max_wire_version)
app-59f4c69fff-4n2jr: pymongo.errors.OperationFailure: user is not allowed to do action [find] on [test1.hits_collection], full error: {'ok': 0, 'errmsg': 'user is not allowed to do action [find] on [test1.hits_collection]', 'code': 8000, 'codeName': 'AtlasError'}
^CERRO[0002] error reading websocket: read tcp 192.168.1.69:51483->3.20.179.85:443: use of closed network connection 

From MongoDB console:

Notice that tbith he admin and user both get overwritten for DB name - test3

Screen Shot 2023-12-11 at 5 39 48 PM

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions