From efb4261305bb0d297de622a4b974ad08b01d40af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jose=20C=2E=20Mass=C3=B3n?= <939888+Abuelodelanada@users.noreply.github.com> Date: Wed, 26 Jul 2023 19:48:48 -0300 Subject: [PATCH] fix Alertmanager settings to use proper scheme (#291) * fix Alertmanager settings to use proper scheme * update grafana_source lib --- src/charm.py | 4 ++-- tests/unit/test_charm.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/charm.py b/src/charm.py index ef3441c78..9c6fb032b 100755 --- a/src/charm.py +++ b/src/charm.py @@ -379,13 +379,13 @@ def _alerting_config(self) -> str: to send notifications to. """ alerting_config = "" - alertmanagers = self.alertmanager_consumer.get_cluster_info() + alertmanagers = self.alertmanager_consumer.get_cluster_info_with_scheme() if not alertmanagers: logger.debug("No alertmanagers available") return alerting_config - return ",".join([f"http://{am}" for am in alertmanagers]) + return ",".join(alertmanagers) def _running_config(self) -> Dict[str, Any]: """Get the on-disk Loki config.""" diff --git a/tests/unit/test_charm.py b/tests/unit/test_charm.py index 99dcd61be..4c1f84d98 100644 --- a/tests/unit/test_charm.py +++ b/tests/unit/test_charm.py @@ -127,14 +127,14 @@ def setUp(self, *_): def test__alerting_config(self): self.harness.charm.alertmanager_consumer = Mock() - self.harness.charm.alertmanager_consumer.get_cluster_info.return_value = [ - "10.1.2.52", - "10.1.3.52", + self.harness.charm.alertmanager_consumer.get_cluster_info_with_scheme.return_value = [ + "http://10.1.2.52", + "http://10.1.3.52", ] expected_value = "http://10.1.2.52,http://10.1.3.52" self.assertEqual(self.harness.charm._alerting_config(), expected_value) - self.harness.charm.alertmanager_consumer.get_cluster_info.return_value = [] + self.harness.charm.alertmanager_consumer.get_cluster_info_with_scheme.return_value = [] expected_value = "" self.assertEqual(self.harness.charm._alerting_config(), expected_value)