From a33ecb364ed7366650ac975ceb9bde18574bc6ff Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 13 Jan 2025 14:34:39 +0900 Subject: [PATCH 1/4] Ignore false-positive E231 error ... and refactor the logic to generate request url. Change-Id: Ic39b7b70a3a1260e0dc281408ba49f8b9ec21c47 (cherry picked from commit 33657191fb862ad48d04a6e43147b5799b6f202c) --- observabilityclient/prometheus_client.py | 10 ++++++---- observabilityclient/utils/metric_utils.py | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/observabilityclient/prometheus_client.py b/observabilityclient/prometheus_client.py index 5380a8d..68483f8 100644 --- a/observabilityclient/prometheus_client.py +++ b/observabilityclient/prometheus_client.py @@ -68,9 +68,12 @@ def set_client_cert(self, client_cert, client_key): def set_basic_auth(self, auth_user, auth_password): self._session.auth = (auth_user, auth_password) + def _get_url(self, endpoint): + scheme = 'https' if self._session.verify else 'http' + return f"{scheme}://{self._host}/api/v1/{endpoint}" # noqa: E231 + def _get(self, endpoint, params=None): - url = (f"{'https' if self._session.verify else 'http'}://" - f"{self._host}/api/v1/{endpoint}") + url = self._get_url(endpoint) resp = self._session.get(url, params=params, headers={'Accept': 'application/json'}) if resp.status_code != requests.codes.ok: @@ -82,8 +85,7 @@ def _get(self, endpoint, params=None): return decoded def _post(self, endpoint, params=None): - url = (f"{'https' if self._session.verify else 'http'}://" - f"{self._host}/api/v1/{endpoint}") + url = self._get_url(endpoint) resp = self._session.post(url, params=params, headers={'Accept': 'application/json'}) if resp.status_code != requests.codes.ok: diff --git a/observabilityclient/utils/metric_utils.py b/observabilityclient/utils/metric_utils.py index ba70b9a..6b1826b 100644 --- a/observabilityclient/utils/metric_utils.py +++ b/observabilityclient/utils/metric_utils.py @@ -68,7 +68,7 @@ def get_prometheus_client(): if host is None or port is None: raise ConfigurationError("Can't find prometheus host and " "port configuration.") - client = PrometheusAPIClient(f"{host}:{port}") + client = PrometheusAPIClient(f"{host}:{port}") # noqa: E231 if ca_cert is not None: client.set_ca_cert(ca_cert) return client From 1f087b042751aa1133252b0e5cd7f1e5b9dc6900 Mon Sep 17 00:00:00 2001 From: OpenStack Release Bot Date: Fri, 7 Mar 2025 14:45:39 +0000 Subject: [PATCH 2/4] Update .gitreview for stable/2025.1 Change-Id: Ibe6b8df5aa52bb5e662b5d518e2661c5b1f3499a --- .gitreview | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitreview b/.gitreview index 45314a6..12f531c 100644 --- a/.gitreview +++ b/.gitreview @@ -2,4 +2,4 @@ host=review.opendev.org port=29418 project=openstack/python-observabilityclient.git -defaultbranch=master +defaultbranch=stable/2025.1 From d2884e48ce3d4609b7900964eecd8be39558ce77 Mon Sep 17 00:00:00 2001 From: OpenStack Release Bot Date: Fri, 7 Mar 2025 14:45:42 +0000 Subject: [PATCH 3/4] Update TOX_CONSTRAINTS_FILE for stable/2025.1 Update the URL to the upper-constraints file to point to the redirect rule on releases.openstack.org so that anyone working on this branch will switch to the correct upper-constraints list automatically when the requirements repository branches. Until the requirements repository has as stable/2025.1 branch, tests will continue to use the upper-constraints list on master. Change-Id: I7c06159b89a7459da68e77ab4a90a15e2ddd160c --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index ec7296b..06da827 100644 --- a/tox.ini +++ b/tox.ini @@ -14,7 +14,7 @@ passenv = PROMETHEUS_* OBSERVABILITY_* deps = - -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} + -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/2025.1} -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt From 93a969a99f44765b0eeef568fafb9aa410e3c1a4 Mon Sep 17 00:00:00 2001 From: Jaromir Wysoglad Date: Wed, 9 Apr 2025 07:57:49 -0400 Subject: [PATCH 4/4] Fix observabilityclient-dsvm-functional job There were some changes to the sg-core devstack plugin, to which we need to react. These changes are similar to what was done in the telemetry-tempest-plugin recently: https://review.opendev.org/c/openstack/telemetry-tempest-plugin/+/945108 https://review.opendev.org/c/openstack/telemetry-tempest-plugin/+/937371 Use PROMETHEUS_CUSTOM_SCRAPE_TARGETS to pass sg_core scrape endpoint https://review.opendev.org/c/openstack/devstack-plugin-prometheus/+/950476 adds the support for passing custom prometheus scrape target in d-p-p. Let's use the same to pass sg_core endpoint. Cherry-picked from these 2 commits on master, without conflicts (both at once need to be applied to pass CI): 2fc3646ac5ce2a58307c0ea2c6d9a99033829a43 34781c5e4f232ffcc4440c7835ac3b9499c15552 Change-Id: I5c1885a3ca9d732d41db140a0feb4c87925b5a48 Co-Authored-By: Chandan Kumar (raukadah) Signed-off-by: Elod Illes Signed-off-by: Jaromir Wysoglad --- .zuul.yaml | 12 ++++++++++-- observabilityclient/tests/functional/test_cli.py | 4 ++-- .../tests/functional/test_python_api.py | 4 ++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.zuul.yaml b/.zuul.yaml index d26f572..a1cbb9c 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -8,16 +8,24 @@ required-projects: - openstack/python-observabilityclient - openstack/ceilometer - - infrawatch/sg-core + - openstack-k8s-operators/sg-core + - openstack/devstack-plugin-prometheus timeout: 4200 vars: devstack_localrc: USE_PYTHON3: True PROMETHEUS_SERVICE_SCRAPE_TARGETS: prometheus,sg-core CEILOMETER_BACKEND: sg-core + PROMETHEUS_CUSTOM_SCRAPE_TARGETS: "localhost:3000,localhost:9090" devstack_plugins: - sg-core: https://github.com/infrawatch/sg-core + sg-core: https://github.com/openstack-k8s-operators/sg-core ceilometer: https://opendev.org/openstack/ceilometer + devstack-plugin-prometheus: https://opendev.org/openstack/devstack-plugin-prometheus + devstack_services: + node_exporter: false + zuul_copy_output: + /etc/prometheus/prometheus.yml: logs + /etc/openstack/prometheus.yaml: logs - project: queue: telemetry diff --git a/observabilityclient/tests/functional/test_cli.py b/observabilityclient/tests/functional/test_cli.py index 626be60..4a8c053 100644 --- a/observabilityclient/tests/functional/test_cli.py +++ b/observabilityclient/tests/functional/test_cli.py @@ -88,7 +88,7 @@ def test_show(self): metric["__name__"] ) self.assertEqual( - "sg-core", + "custom", metric["job"] ) @@ -103,7 +103,7 @@ def test_query(self): metric["__name__"] ) self.assertEqual( - "sg-core", + "custom", metric["job"] ) diff --git a/observabilityclient/tests/functional/test_python_api.py b/observabilityclient/tests/functional/test_python_api.py index 8f3bf85..162b7d8 100644 --- a/observabilityclient/tests/functional/test_python_api.py +++ b/observabilityclient/tests/functional/test_python_api.py @@ -52,7 +52,7 @@ def test_show(self): for metric in ret: self.assertEqual("ceilometer_image_size", metric.labels["__name__"]) - self.assertEqual("sg-core", + self.assertEqual("custom", metric.labels["job"]) def test_query(self): @@ -62,7 +62,7 @@ def test_query(self): for metric in ret: self.assertEqual("ceilometer_image_size", metric.labels["__name__"]) - self.assertEqual("sg-core", metric.labels["job"]) + self.assertEqual("custom", metric.labels["job"]) class PythonAPITestFunctionalAdminCommands(base.PythonAPITestCase):