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 <cbelu@cloudbasesolutions.com>
This commit is contained in:
Claudiu Belu
2025-09-12 07:48:45 +00:00
parent bea759a56b
commit 9cdb254685
2 changed files with 9 additions and 5 deletions

View File

@@ -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(

View File

@@ -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"],
}