diff --git a/harbor/changelog.d/17194.fixed b/harbor/changelog.d/17194.fixed new file mode 100644 index 0000000000000..4edb5aa18ce39 --- /dev/null +++ b/harbor/changelog.d/17194.fixed @@ -0,0 +1 @@ +Add missing custom tags to the `can_connect` service check diff --git a/harbor/datadog_checks/harbor/harbor.py b/harbor/datadog_checks/harbor/harbor.py index 251a602a7b577..f51e2620bae65 100644 --- a/harbor/datadog_checks/harbor/harbor.py +++ b/harbor/datadog_checks/harbor/harbor.py @@ -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) diff --git a/harbor/tests/common.py b/harbor/tests/common.py index 4e477ad48ea14..6d7b5924633a9 100644 --- a/harbor/tests/common.py +++ b/harbor/tests/common.py @@ -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", diff --git a/harbor/tests/test_harbor.py b/harbor/tests/test_harbor.py index 4296c7613ad7e..439408e84efc8 100644 --- a/harbor/tests/test_harbor.py +++ b/harbor/tests/test_harbor.py @@ -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'] + )