diff --git a/src/charm.py b/src/charm.py index caf195e..894b996 100755 --- a/src/charm.py +++ b/src/charm.py @@ -14,6 +14,7 @@ from ops.framework import ( StoredState, ) from ops.main import main +import ops.model import charmhelpers.core.host as ch_host import charmhelpers.core.templating as ch_templating import interface_ceph_client @@ -98,6 +99,9 @@ class CephISCSIGatewayCharmBase(ops_openstack.OSBaseCharm): DEFAULT_TARGET = "iqn.2003-01.com.ubuntu.iscsi-gw:iscsi-igw" REQUIRED_RELATIONS = ['ceph-client', 'cluster'] + # Two has been tested before is probably fine too but needs + # validating + ALLOWED_UNIT_COUNTS = [2] def __init__(self, framework, key): super().__init__(framework, key) @@ -287,6 +291,13 @@ class CephISCSIGatewayCharmBase(ops_openstack.OSBaseCharm): self.state.enable_tls = True self.on_pools_available(event) + def custom_status_check(self): + 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)) + return False + return True + @ops_openstack.charm_class class CephISCSIGatewayCharmJewel(CephISCSIGatewayCharmBase): diff --git a/src/interface_ceph_iscsi_peer.py b/src/interface_ceph_iscsi_peer.py index ca156f3..0d2067c 100644 --- a/src/interface_ceph_iscsi_peer.py +++ b/src/interface_ceph_iscsi_peer.py @@ -100,3 +100,12 @@ class CephISCSIGatewayPeers(Object): for u in self.peer_rel.units: addresses.append(self.peer_rel.data[u]['ingress-address']) return sorted(addresses) + + @property + def peer_count(self): + return len(self.peer_rel.units) + + @property + def unit_count(self): + return len(self.peer_rel.units) + 1 + diff --git a/tests/bundles/focal.yaml b/tests/bundles/focal.yaml index 19b7281..2d0cac8 100644 --- a/tests/bundles/focal.yaml +++ b/tests/bundles/focal.yaml @@ -1,14 +1,31 @@ -series: bionic +series: focal +machines: + '0': + constraints: mem=3072M + '1': + '2': + '3': + '4': + '5': + '6': + series: bionic + '7': + series: bionic + '8': applications: ubuntu: charm: cs:ubuntu num_units: 1 + to: + - '8' ceph-iscsi: charm: ../../ - series: focal num_units: 2 options: rbd-metadata-pool: tmbtil + to: + - '0' + - '1' ceph-osd: charm: cs:~gnuoy/ceph-osd-5 num_units: 3 @@ -16,23 +33,35 @@ applications: osd-devices: 'cinder,10G' options: osd-devices: '/dev/test-non-existent' - source: cloud:bionic-train + to: + - '0' + - '1' + - '2' ceph-mon: charm: cs:~gnuoy/ceph-mon-6 num_units: 3 options: monitor-count: '3' - source: cloud:bionic-train + to: + - '3' + - '4' + - '5' vault: + series: bionic num_units: 1 # charm: cs:~openstack-charmers-next/vault charm: cs:~gnuoy/vault-29 + to: + - '6' mysql: + series: bionic charm: cs:~openstack-charmers-next/percona-cluster num_units: 1 options: innodb-buffer-pool-size: 256M max-connections: 1000 + to: + - '7' relations: - - ceph-mon:client - ceph-iscsi:ceph-client