MongoDB Health Check fails when using Mongo template on Openshift
See original GitHub issueDescribe the bug When configuring an application to point to a mongoDB instance deployed using the standard Openshift templates, the health check fails as it does not have the permissions to connect to the admin database. The openshift template creates an user with ReadWrite permissions that does not have the required permissions to list databases in admin db. There is also no config property to specify the admin password.
Expected behavior Expect the health check to return a good status
Actual behavior Health check fails with the following error message:
checks": [
{
"name": "MongoDB connection health check",
"status": "DOWN",
"data": {
"reason": "Command failed with error 13 (Unauthorized): 'not authorized on admin to execute command { listDatabases: 1, nameOnly: true, $db: \"admin\" }' on server mongodb:27017. The full response is {\"ok\": 0.0, \"errmsg\": \"not authorized on admin to execute command { listDatabases: 1, nameOnly: true, $db: \\\"admin\\\" }\", \"code\": 13, \"codeName\": \"Unauthorized\"}"
}
}
To Reproduce Steps to reproduce the behavior:
- Deploy a mongo db instance using the standard Openshift template:
oc new-app --template=mongodb-ephemeral --param=MONGODB_DATABASE=catalog -n ${namespace}
- Deploy a simple application that uses panache/mongodb configured to connect with the normal user account provisioned by the Openshift template
- Enable the smallrye-health extension
- Verify /health or /health/ready endpoint
Configuration
# Add your application.properties here, if applicable.
quarkus.mongodb.connection-string = mongodb://mongodb:27017
quarkus.mongodb.database = catalog
quarkus.mongodb.credentials.username = [generated username]
quarkus.mongodb.credentials.password = [ generated password]
Environment (please complete the following information):
- Output of
uname -a
orver
: Openshift 4.x (ubi-minimal), pod: 4.18.0-147.5.1.el8_1.x86_64 - Output of
java -version
:
openjdk version "11.0.7" 2020-04-14 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.7+10-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.7+10-LTS, mixed mode, sharing)
- GraalVM version (if different from Java): 20.0.0
- Quarkus version or git rev: 1.5.0-Final
- Build tool (ie. output of
mvnw --version
orgradlew --version
): 3.6.3 Additional context (Add any other context about the problem here.)
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Simple HTTP/TCP health check for MongoDB - Stack Overflow
I've created a simple health check for mongodb, it uses the mongo client to send a simple query request (eg. db.stats() ) to...
Read more >MongoDB - Database Images - OpenShift Documentation
OpenShift Dedicated provides a container image for running MongoDB. This image can provide database services based on username, password, and database name ...
Read more >MongoSocketReadException during Health Checks - MongoDB
My application is a spring boot microservices application which uses Mongo DB as its database. Our MongoDB cluster is a 5 server replica...
Read more >MongoDB | Using Images | OpenShift Origin Branch Build
Creating a Database Service from a Template; Using MongoDB Replication. Creating the Deployment Configuration; Creating the Service Pod; Creating a Headless ...
Read more >Monitoring MongoDB Performance Metrics (WiredTiger)
The replica set member state is an integer indicating the current status of a node in a replica set. You should alert on...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Doing this will change the response of the health check endpoint (the databases list is included inside the response). This will be a breaking change. I need to discuss with others to see what they think about it.
Or maybe I can fallback on using the
ping
command in case ofUnauthorized
exception but I’m not fan of this either.ping
seems to be the better command to run.