From b7f9d994910c533b72ade4175f2faf0fc6262f80 Mon Sep 17 00:00:00 2001 From: Guillaume Boutry Date: Tue, 5 Mar 2024 14:53:34 +0100 Subject: [PATCH] Call request pool on config changed for cinder ceph Cinder ceph does not re-request a pool on config changed, which meant it was not responding to changes from configuration keys such as replication factor. Change-Id: I4e943cf9b40554280e104cb2090ecfc043f3afbb --- charms/cinder-ceph-k8s/src/charm.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/charms/cinder-ceph-k8s/src/charm.py b/charms/cinder-ceph-k8s/src/charm.py index ea439802..e700d9a2 100755 --- a/charms/cinder-ceph-k8s/src/charm.py +++ b/charms/cinder-ceph-k8s/src/charm.py @@ -225,6 +225,13 @@ class CinderCephOperatorCharm(charm.OSBaseOperatorCharmK8S): super().__init__(framework) self._state.set_default(api_ready=False) + def configure_charm(self, event: ops.EventBase): + """Catchall handler to configure charm services.""" + super().configure_charm(event) + if self.has_ceph_relation() and self.ceph.ready: + logger.info("CONFIG changed and ceph ready: calling request pools") + self.ceph.request_pools(event) + def get_relation_handlers(self) -> List[relation_handlers.RelationHandler]: """Relation handlers for the service.""" handlers = super().get_relation_handlers() @@ -265,6 +272,13 @@ class CinderCephOperatorCharm(charm.OSBaseOperatorCharmK8S): ) ] + def has_ceph_relation(self) -> bool: + """Returns whether or not the application has been related to Ceph. + + :return: True if the ceph relation has been made, False otherwise. + """ + return self.model.get_relation("ceph") is not None + def api_ready(self, event) -> None: """Event handler for bootstrap of service when api services are ready.""" self._state.api_ready = True