From 9cdb2546856b37877707aead82412717792c65ce Mon Sep 17 00:00:00 2001 From: Claudiu Belu Date: Fri, 12 Sep 2025 07:48:45 +0000 Subject: [PATCH] fix: inconsistent ceph-nfs relation mon_hosts key The CephNfsProvides set the mon_hosts key, while the CephNfsRequires accesses mon-hosts. xref: https://github.com/canonical/charm-microceph/pull/200 Change-Id: Ib00947ed47fac6c82b25eea2dfe37b19649a716b Signed-off-by: Claudiu Belu --- charms/manila-cephfs-k8s/tests/unit/test_charm.py | 5 +++-- .../lib/charms/ceph_nfs_client/v0/ceph_nfs_client.py | 9 ++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/charms/manila-cephfs-k8s/tests/unit/test_charm.py b/charms/manila-cephfs-k8s/tests/unit/test_charm.py index ba2d9728..2a1532b8 100644 --- a/charms/manila-cephfs-k8s/tests/unit/test_charm.py +++ b/charms/manila-cephfs-k8s/tests/unit/test_charm.py @@ -17,6 +17,7 @@ """Unit tests for the Manila Share (Cephfs) K8s Operator charm.""" import charm +import charms.ceph_nfs_client.v0.ceph_nfs_client as ceph_nfs_client import charms.manila_k8s.v0.manila as manila_k8s import ops_sunbeam.test_utils as test_utils from ops import ( @@ -84,10 +85,10 @@ class TestManilaCephfsCharm(test_utils.CharmTestCase): """Add the ceph-nfs relation and unit data.""" app_data = { "client": "client.foo", - "cluster-id": "lish", + ceph_nfs_client.CLUSTER_ID: "lish", "fsid": "fake-fsid", "keyring": "keys-do-not-ring", - "mon-hosts": '["mony"]', + ceph_nfs_client.MON_HOSTS: '["mony"]', "volume": "voly", } return self.harness.add_relation( diff --git a/libs/external/lib/charms/ceph_nfs_client/v0/ceph_nfs_client.py b/libs/external/lib/charms/ceph_nfs_client/v0/ceph_nfs_client.py index da61379c..596a6335 100644 --- a/libs/external/lib/charms/ceph_nfs_client/v0/ceph_nfs_client.py +++ b/libs/external/lib/charms/ceph_nfs_client/v0/ceph_nfs_client.py @@ -82,6 +82,9 @@ LIBAPI = 0 # to 0 if you are raising the major API version LIBPATCH = 1 +MON_HOSTS = "mon_hosts" +CLUSTER_ID = "cluster-id" + logger = logging.getLogger(__name__) @@ -152,13 +155,13 @@ class CephNfsRequires(Object): if not relation_data: return {} - mon_hosts = json.loads(relation_data["mon-hosts"]) + mon_hosts = json.loads(relation_data[MON_HOSTS]) return { "client": relation_data["client"], "keyring": relation_data["keyring"], - "mon_hosts": mon_hosts, - "cluster-id": relation_data["cluster-id"], + MON_HOSTS: mon_hosts, + CLUSTER_ID: relation_data[CLUSTER_ID], "volume": relation_data["volume"], "fsid": relation_data["fsid"], }