Skip to content
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

[mongo] repairing of mongodb.can_connect check #2658

Merged
merged 1 commit into from Aug 22, 2016

Conversation

cryptspirit
Copy link
Contributor

Connection to database going in db.command function, but the call of this function happens outside of exception block. The check can't catch unreachable instances and integration check mongodb.can_connect doesn't work properly

@cryptspirit cryptspirit changed the title repairing of mongodb.can_connect check [mongo] repairing of mongodb.can_connect check Jul 7, 2016
@degemer
Copy link
Member

degemer commented Jul 27, 2016

Thanks for the PR @cryptspirit !
I think there may be an issue if the connection requires authentification though: status = db.command('serverStatus', tcmalloc=collect_tcmalloc_metrics) happens before db.authenticate(username, password).

What do you think of something like this instead ?

try:
     status = db.command('serverStatus', tcmalloc=collect_tcmalloc_metrics)
except Exception:
    self.service_check(
        self.SERVICE_CHECK_NAME,
        AgentCheck.CRITICAL,
        tags=service_check_tags)
    raise
else:
    self.service_check(
        self.SERVICE_CHECK_NAME,
        AgentCheck.OK,
        tags=service_check_tags)

@cryptspirit
Copy link
Contributor Author

@degemer right. there is need to add separate exception block for serverStatus execution

@degemer
Copy link
Member

degemer commented Jul 28, 2016

@cryptspirit would you like to update your PR with this change then ? (if you don't have the time, we can open another one)

@cryptspirit
Copy link
Contributor Author

I will

@degemer
Copy link
Member

degemer commented Aug 22, 2016

Thank you @cryptspirit ! (and sorry for the delay)
Merging.

@degemer degemer added this to the 5.9.0 milestone Aug 22, 2016
@degemer degemer merged commit e30efa3 into DataDog:master Aug 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants