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

Add missing custom tags to the can_connect service check #17194

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions harbor/changelog.d/17194.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add missing custom tags to the `can_connect` service check
4 changes: 2 additions & 2 deletions harbor/datadog_checks/harbor/harbor.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def check(self, instance):
self._submit_read_only_status(api, tags)
except Exception:
self.log.exception("An error occurred when collecting Harbor metrics")
self.service_check(CAN_CONNECT, AgentCheck.CRITICAL)
self.service_check(CAN_CONNECT, AgentCheck.CRITICAL, tags)
raise
else:
self.service_check(CAN_CONNECT, AgentCheck.OK)
self.service_check(CAN_CONNECT, AgentCheck.OK, tags)
4 changes: 2 additions & 2 deletions harbor/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

HERE = os.path.dirname(os.path.abspath(__file__))
URL = 'http://{}'.format(get_docker_hostname())
INSTANCE = {'url': URL, 'username': 'NotAnAdmin', 'password': 'Str0ngPassw0rd'}
ADMIN_INSTANCE = {'url': URL, 'username': 'admin', 'password': 'Harbor12345'}
INSTANCE = {'url': URL, 'username': 'NotAnAdmin', 'password': 'Str0ngPassw0rd', 'tags': ['environment:test']}
ADMIN_INSTANCE = {'url': URL, 'username': 'admin', 'password': 'Harbor12345', 'tags': ['environment:test']}

HEALTH_FIXTURE = {
"status": "healthy",
Expand Down
6 changes: 4 additions & 2 deletions harbor/tests/test_harbor.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def assert_basic_case(aggregator):


def assert_service_checks(aggregator):
aggregator.assert_service_check('harbor.can_connect', status=HarborCheck.OK)
aggregator.assert_service_check('harbor.can_connect', status=HarborCheck.OK, tags=['environment:test'])
for c in HARBOR_COMPONENTS:
aggregator.assert_service_check('harbor.status', status=mock.ANY, tags=['component:{}'.format(c)])
aggregator.assert_service_check(
'harbor.status', status=mock.ANY, tags=['component:{}'.format(c), 'environment:test']
)
Loading