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

[couchdb] Improve error handling and add Blacklist support. #1760

Merged
merged 1 commit into from
Aug 19, 2015
Merged

[couchdb] Improve error handling and add Blacklist support. #1760

merged 1 commit into from
Aug 19, 2015

Conversation

irabinovitch
Copy link
Contributor

  • fail gracefully when one or more individual dbs are not readable by the configured user.
  • allow blacklisting of specific databases via db_blacklist in couch.yaml
  • append to blacklist at run time if unable to query a given db's stats

@@ -18,6 +18,7 @@ class CouchDb(AgentCheck):
SERVICE_CHECK_NAME = 'couchdb.can_connect'
SOURCE_TYPE_NAME = 'couchdb'
TIMEOUT = 5
db_blacklist = []
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this won't play well in the (unlikely) case where you are monitoring multiple instances of couchdb on a single server, and if they have some database names in common.

If you want to blacklist one of these db in one of this instance, you'll end up blacklisting it for all instances.

So, the best (but kind of ugly) solution is to use a dictionary instead of a list whose keys are unique keys of an instance (e.g. the "server" parameter of the configuration).

Let me know if you have more questions

@remh
Copy link

remh commented Jul 9, 2015

Nice first pass! I made a few comments (mostly nitpicks).

Do you think it's possible to extend the tests to test this scenario as well ?

@irabinovitch
Copy link
Contributor Author

@remh thanks for the feedback. Yes, we should be able to extend the tests. I'll take a stab at it tomorrow.

@remh
Copy link

remh commented Jul 17, 2015

This fixes #1749

couchdb['databases'][dbName] = None
if e.response.status_code == 403:
self.db_blacklist[server].append(dbName)
self.warning('Database %s is not readable by the configured user. It will be added to the blacklist. Please restart then agent to clear.' % dbName)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo, should be:
Please restart THE agent to clear

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

- fail gracefully when one or more individual dbs are not readable by the configured user.
- allow blacklisting of specific databases via db_blacklist in couch.yaml
- append to blacklist at run time if unable to query a given db's stats
- add tests for whitelist and blacklist functionality
- add tests for global metrics in addition to per db metrics
- add tests to verify error handling around restricted databases.
- add tests to test user authentication
@irabinovitch
Copy link
Contributor Author

@remh @JohnLZeller OK. All tests are passing and I believe this is complete. Let me know if you have any further comments you'd like me to address.

@JohnLZeller
Copy link
Contributor

Thanks @irabinovitch! I'll take a look here shortly

@JohnLZeller
Copy link
Contributor

lgtm, good work :) 👍

JohnLZeller added a commit that referenced this pull request Aug 19, 2015
[couchdb] Improve error handling and add Blacklist support
@JohnLZeller JohnLZeller merged commit 89fa1d7 into DataDog:master Aug 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants