question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MongoDB Health Check fails when using Mongo template on Openshift

See original GitHub issue

Describe 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:

  1. Deploy a mongo db instance using the standard Openshift template:
oc new-app --template=mongodb-ephemeral --param=MONGODB_DATABASE=catalog -n ${namespace}
  1. Deploy a simple application that uses panache/mongodb configured to connect with the normal user account provisioned by the Openshift template
  2. Enable the smallrye-health extension
  3. 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 or ver: 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 or gradlew --version): 3.6.3 Additional context (Add any other context about the problem here.)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
loicmathieucommented, Jun 19, 2020

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 of Unauthorized exception but I’m not fan of this either.

0reactions
loicmathieucommented, Jun 19, 2020

ping seems to be the better command to run.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found