From fdf5dec34c47e85254f7a289c42b21675f324bfc Mon Sep 17 00:00:00 2001 From: Liam Young Date: Fri, 1 May 2020 07:26:47 +0000 Subject: [PATCH] General fixes * Specify minimum Juju version * Stop cluster count block being overwritted on setup * Fix cluster count in peer relation when relation is not ready * Move location of ops-openstack to openstack-charmers --- .gitmodules | 2 +- metadata.yaml | 1 + mod/ops-openstack | 2 +- src/charm.py | 11 +++++++++++ src/interface_ceph_iscsi_peer.py | 7 +++++-- 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.gitmodules b/.gitmodules index cc44e0e..6386c4f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -6,7 +6,7 @@ url = https://github.com/gnuoy/oper-interface-ceph-client.git [submodule "mod/ops-openstack"] path = mod/ops-openstack - url = https://github.com/gnuoy/ops-openstack.git + url = https://github.com/openstack-charmers/ops-openstack.git [submodule "mod/charm-helpers"] path = mod/charm-helpers url = https://github.com/juju/charm-helpers.git diff --git a/metadata.yaml b/metadata.yaml index c809f86..0f3c7f6 100644 --- a/metadata.yaml +++ b/metadata.yaml @@ -12,6 +12,7 @@ tags: series: - focal subordinate: false +min-juju-version: 2.7.6 extra-bindings: public: cluster: diff --git a/mod/ops-openstack b/mod/ops-openstack index 58c9f30..18b8f1f 160000 --- a/mod/ops-openstack +++ b/mod/ops-openstack @@ -1 +1 @@ -Subproject commit 58c9f3093ecc8c1797272d7a6720d7f8ef2d39aa +Subproject commit 18b8f1fcfe7bee87217e7d3152e377c2c3e3f2ff diff --git a/src/charm.py b/src/charm.py index 6a4343e..bef471b 100755 --- a/src/charm.py +++ b/src/charm.py @@ -131,6 +131,13 @@ class CephISCSIGatewayCharmBase(ops_openstack.OSBaseCharm): self.framework.observe(self.on.config_changed, self) self.framework.observe(self.on.upgrade_charm, self) + def on_install(self, event): + if ch_host.is_container(): + logging.info("Installing into a container is not supported") + self.update_status() + else: + self.install_pkgs() + def on_add_trusted_ip_action(self, event): self.state.additional_trusted_ips.append( event.params['ips'].split(' ')) @@ -296,6 +303,10 @@ class CephISCSIGatewayCharmBase(ops_openstack.OSBaseCharm): self.on_pools_available(event) def custom_status_check(self): + if ch_host.is_container(): + self.unit.status = ops.model.BlockedStatus( + 'Charm cannot be deployed into a container') + return False if self.peers.unit_count not in self.ALLOWED_UNIT_COUNTS: self.unit.status = ops.model.BlockedStatus( '{} is an invalid unit count'.format(self.peers.unit_count)) diff --git a/src/interface_ceph_iscsi_peer.py b/src/interface_ceph_iscsi_peer.py index beeac30..20eba6d 100644 --- a/src/interface_ceph_iscsi_peer.py +++ b/src/interface_ceph_iscsi_peer.py @@ -102,8 +102,11 @@ class CephISCSIGatewayPeers(Object): @property def peer_count(self): - return len(self.peer_rel.units) + if self.peer_rel: + return len(self.peer_rel.units) + else: + return 0 @property def unit_count(self): - return len(self.peer_rel.units) + 1 + return self.peer_count + 1