Skip to content

Commit

Permalink
Add missing custom tags to the can_connect service check (#17194)
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorentClarret authored Mar 15, 2024
1 parent 54f36f5 commit 60818e2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
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']
)

0 comments on commit 60818e2

Please sign in to comment.