-
-
Notifications
You must be signed in to change notification settings - Fork 187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't connect to dockerized mongodb-memory-server replica set running as a service in GitLab #815
Comments
mongodb-memory-server is not meant to run as a service and is meant to directly run as setup in a testing engine (or some playground like node repl), and so the default are adjusted to that, which means by default ports a generated if they are blocked, and unless as i am not allowed to view the log, i cannot say for sure what is happening, but it is likely that a different port than if you should post the log (or i somehow gain access) make sure Debug logs are enabled |
Thanks a lot for your reply If I want the job logs to be public I have to disable the debug. Here is the job logs available for unauthenticated users If I enable debug, the full log is attached here. As per GitLab services documentation If the problem is, like you suggest, the force port not being set, I guess there is no workaround yet for replica set? |
it seems like there is some kind of misunderstanding, i am asking about mongodb-memory-server debug logs, which can be enabled either via the package.json or as a environment variable (recommended), not via gitlab ci debug mode once debug logging is enabled, you should see something along the lines of: MongoMS:MongoMemoryServer create: Called .create() method +0ms
MongoMS:MongoMemoryServer Mongo[unknown]: start: Called .start() method +2ms
MongoMS:MongoMemoryServer Mongo[unknown]: _startUpInstance: Called MongoMemoryServer._startUpInstance() method +2ms
MongoMS:MongoMemoryServer Mongo[unknown]: getStartOptions: forceSamePort: false +1ms |
Ah, yes, sorry. I've made the DEBUG mode configurable so that I can decide at runtime whether to enable or disable debug traces
Complete log of the container running as a GitLab service attached here. I can see some relevant traces such as
Hopefully it helps. Thanks again |
with those it is clear that the port specified is actually used, so no port is generated
what should a healthcheck change aside from showing what status the service is in? is it actually showing as connected (if the status is visible) as can be seen in the following log, your driver actually connects, but somehow closes the connection again: 2023-10-18T18:23:56.993Z MongoMS:MongoInstance Mongo[27017]: stdoutHandler: ""{"t":{"$date":"2023-10-18T18:23:56.993+00:00"},"s":"I", "c":"NETWORK", "id":22943, "ctx":"listener","msg":"Connection accepted","attr":{"remote":"172.17.0.4:54396","uuid":"c58674ac-2641-4466-905a-3118f5df3604","connectionId":9,"connectionCount":1}}""
2023-10-18T18:23:56.994Z MongoMS:MongoInstance Mongo[27017]: stdoutHandler: ""{"t":{"$date":"2023-10-18T18:23:56.993+00:00"},"s":"I", "c":"NETWORK", "id":22943, "ctx":"listener","msg":"Connection accepted","attr":{"remote":"172.17.0.4:54398","uuid":"a1587c15-8fdc-4d6c-97bf-0dc6881aff59","connectionId":10,"connectionCount":2}}""
2023-10-18T18:23:57.032Z MongoMS:MongoInstance Mongo[27017]: stdoutHandler: ""{"t":{"$date":"2023-10-18T18:23:57.032+00:00"},"s":"I", "c":"NETWORK", "id":51800, "ctx":"conn9","msg":"client metadata","attr":{"remote":"172.17.0.4:54396","client":"conn9","doc":{"driver":{"name":"mongo-csharp-driver","version":"2.22.0.0"},"os":{"type":"Linux","name":"Linux 5.4.109+ #1 SMP Wed Jun 16 20:00:10 PDT 2021","architecture":"x86_64","version":"5.4.109+"},"platform":".NET 7.0.12"}}}""
2023-10-18T18:23:57.032Z MongoMS:MongoInstance Mongo[27017]: stdoutHandler: ""{"t":{"$date":"2023-10-18T18:23:57.032+00:00"},"s":"I", "c":"NETWORK", "id":51800, "ctx":"conn10","msg":"client metadata","attr":{"remote":"172.17.0.4:54398","client":"conn10","doc":{"driver":{"name":"mongo-csharp-driver","version":"2.22.0.0"},"os":{"type":"Linux","name":"Linux 5.4.109+ #1 SMP Wed Jun 16 20:00:10 PDT 2021","architecture":"x86_64","version":"5.4.109+"},"platform":".NET 7.0.12"}}}""
2023-10-18T18:23:57.100Z MongoMS:MongoInstance Mongo[27017]: stdoutHandler: ""{"t":{"$date":"2023-10-18T18:23:57.099+00:00"},"s":"I", "c":"NETWORK", "id":22944, "ctx":"conn10","msg":"Connection ended","attr":{"remote":"172.17.0.4:54398","uuid":"a1587c15-8fdc-4d6c-97bf-0dc6881aff59","connectionId":10,"connectionCount":1}}""
2023-10-18T18:23:57.106Z MongoMS:MongoInstance Mongo[27017]: stdoutHandler: ""{"t":{"$date":"2023-10-18T18:23:57.106+00:00"},"s":"I", "c":"NETWORK", "id":22944, "ctx":"conn9","msg":"Connection ended","attr":{"remote":"172.17.0.4:54396","uuid":"c58674ac-2641-4466-905a-3118f5df3604","connectionId":9,"connectionCount":0}}"" maybe you have some kind of driver misconfiguration? i dont know about how the csharp mongodb driver works, so i cant really help with that also it seems like the service is not properly shutdown, not that this would change anything (.stop never being called and just terminated i guess) |
Thanks. I created a different tester project for GitLab CI/CD to leave the C# Mongo Driver out of the picture and use The CI/CD pipeline fails. Log attached Things I found
The command I run in pipeline is
as per my .gitlab-ci.yml |
actually now that i look at the logs again, the drivers are trying to connect to could you maybe print the output of though it is somewhat weird, because the server actually logs a connection attempt, so it is resolved but refused? |
It seems to reject the connection, yes. But I also think it's not a problem of unreachable host/alias as it connects well when not specifying Below it's what the log shows when I display the hosts file. As you can see, in addition to showing
Full raw log here |
just to confirm this has nothing to do with a
this is quite weird and i dont understand as well, because according to gitlabs documentation / issues it should not work and should be: 172.17.0.3 mongors 398338eeb54b runner-ns46nmmj-project-51414559-concurrent-0-e41c37375e72e41f-registry.gitlab.com__sunnyatticsoftware__mongodb-rs-0 personally i dont know anything else to try or suggest to fix this, from what i can tell the server (instance) is configured correctly (it is a replset with correct name, it is the port that is set, it is bound to the documentation suggested all interfaces) |
I think this issue might come from the server discovery logic implemented in many (all?) MongoDB drivers: When the client connects to the replica set via any accessible IP/port, it fetches the list of all replica set members, disconnects and then connects to one (or multiple) of the member hosts it received from the server. I assume in this case the following is happening:
In similar CI/CD setups, I've used the Alternatively, you could explicitly set |
this is currently not possible to be overwritten in MMS, it will always be |
NodeJS: 18
mongodb-memory-server-*: 9.0.1
mongodb(the binary version): ?
mongodb(the js package): 6.1.0
system: Linux / Docker
package: mongo-memory-server
What is your question?
I wonder if there is any mongodb-memory-server configuration that might be involved in the fact that I can't connect to the server when running within a docker container as a GitLab CI/CD service in a pipeline's job.
I created this question in StackOverflow with full details https://stackoverflow.com/q/77315673/2948212
but basically I have dockerized the application here https://gitlab.com/sunnyatticsoftware/mongodb-rs binding IPs to all and using a replica set, and it's all good when I test it locally
and I can properly connect to
mongodb://127.0.0.1:27017/?replicaSet=rs0
And it's also good when I run the docker container and I connect to the application through a hostname alias like
mongors
where there is an entry on my/etc/hosts
pointingmongors
to127.0.0.1
so that I can use connection stringBut in GitLab CI/CD the connectivity fails. See https://gitlab.com/sunnyatticsoftware/mongodb-rs-tester/-/jobs/5319052214
Is this something related to mongodb-memory-server configuration?
The text was updated successfully, but these errors were encountered: