From 6cd096b78b2e35e9a8231d087edefa62f996775a Mon Sep 17 00:00:00 2001 From: Joseph Phillips Date: Wed, 7 Feb 2024 19:10:23 +0100 Subject: [PATCH 1/2] Uses BlockedStatus instead of ErrorStatus, which when set explicitly results in an error with the new version of Ops. --- src/charm.py | 5 +++-- tests/test_charm.py | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/charm.py b/src/charm.py index 302014b..43a5e1e 100755 --- a/src/charm.py +++ b/src/charm.py @@ -12,7 +12,7 @@ from ops.framework import StoredState from ops.charm import RelationJoinedEvent, RelationDepartedEvent from ops.main import main -from ops.model import ActiveStatus, BlockedStatus, ErrorStatus, Relation +from ops.model import ActiveStatus, BlockedStatus, Relation from typing import List logger = logging.getLogger(__name__) @@ -84,7 +84,8 @@ def _on_metrics_endpoint_relation_created(self, event: RelationJoinedEvent): try: api_port = self.api_port() except AgentConfException as e: - self.unit.status = ErrorStatus(f"can't read controller API port from agent.conf: {e}") + self.unit.status = BlockedStatus( + f"can't read controller API port from agent.conf: {e}") return metrics_endpoint = MetricsEndpointProvider( diff --git a/tests/test_charm.py b/tests/test_charm.py index 3d51315..b970ea8 100644 --- a/tests/test_charm.py +++ b/tests/test_charm.py @@ -4,7 +4,7 @@ import os import unittest from charm import JujuControllerCharm, AgentConfException -from ops import ErrorStatus +from ops import BlockedStatus from ops.testing import Harness from unittest.mock import mock_open, patch @@ -140,7 +140,7 @@ def test_apiaddresses_missing_status(self, *_): harness.begin() harness.add_relation('metrics-endpoint', 'prometheus-k8s') - self.assertEqual(harness.charm.unit.status, ErrorStatus( + self.assertEqual(harness.charm.unit.status, BlockedStatus( "can't read controller API port from agent.conf: agent.conf key 'apiaddresses' missing" )) From 209f9c8a0be7ac4cacb86f5fc4f227fcf2bf39c3 Mon Sep 17 00:00:00 2001 From: Joseph Phillips Date: Sat, 10 Feb 2024 14:35:40 +0100 Subject: [PATCH 2/2] Updates charm metadata with correct Juju version restriction. --- metadata.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.yaml b/metadata.yaml index ea1f386..8e62e76 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -2,7 +2,7 @@ # Licensed under the GPLv3, see LICENSE file for details. name: juju-controller assumes: -- juju >= 3.3 +- juju >= 3.5 description: | The Juju controller charm is used to expose various pieces of functionality of a Juju controller.