Unit check and test colocation with osds

This commit is contained in:
Liam Young 2020-04-14 08:39:13 +00:00
parent 5e4817b380
commit 2edf2607d0
3 changed files with 53 additions and 4 deletions

View File

@ -14,6 +14,7 @@ from ops.framework import (
StoredState, StoredState,
) )
from ops.main import main from ops.main import main
import ops.model
import charmhelpers.core.host as ch_host import charmhelpers.core.host as ch_host
import charmhelpers.core.templating as ch_templating import charmhelpers.core.templating as ch_templating
import interface_ceph_client import interface_ceph_client
@ -98,6 +99,9 @@ class CephISCSIGatewayCharmBase(ops_openstack.OSBaseCharm):
DEFAULT_TARGET = "iqn.2003-01.com.ubuntu.iscsi-gw:iscsi-igw" DEFAULT_TARGET = "iqn.2003-01.com.ubuntu.iscsi-gw:iscsi-igw"
REQUIRED_RELATIONS = ['ceph-client', 'cluster'] 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): def __init__(self, framework, key):
super().__init__(framework, key) super().__init__(framework, key)
@ -287,6 +291,13 @@ class CephISCSIGatewayCharmBase(ops_openstack.OSBaseCharm):
self.state.enable_tls = True self.state.enable_tls = True
self.on_pools_available(event) 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 @ops_openstack.charm_class
class CephISCSIGatewayCharmJewel(CephISCSIGatewayCharmBase): class CephISCSIGatewayCharmJewel(CephISCSIGatewayCharmBase):

View File

@ -100,3 +100,12 @@ class CephISCSIGatewayPeers(Object):
for u in self.peer_rel.units: for u in self.peer_rel.units:
addresses.append(self.peer_rel.data[u]['ingress-address']) addresses.append(self.peer_rel.data[u]['ingress-address'])
return sorted(addresses) 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

View File

@ -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: applications:
ubuntu: ubuntu:
charm: cs:ubuntu charm: cs:ubuntu
num_units: 1 num_units: 1
to:
- '8'
ceph-iscsi: ceph-iscsi:
charm: ../../ charm: ../../
series: focal
num_units: 2 num_units: 2
options: options:
rbd-metadata-pool: tmbtil rbd-metadata-pool: tmbtil
to:
- '0'
- '1'
ceph-osd: ceph-osd:
charm: cs:~gnuoy/ceph-osd-5 charm: cs:~gnuoy/ceph-osd-5
num_units: 3 num_units: 3
@ -16,23 +33,35 @@ applications:
osd-devices: 'cinder,10G' osd-devices: 'cinder,10G'
options: options:
osd-devices: '/dev/test-non-existent' osd-devices: '/dev/test-non-existent'
source: cloud:bionic-train to:
- '0'
- '1'
- '2'
ceph-mon: ceph-mon:
charm: cs:~gnuoy/ceph-mon-6 charm: cs:~gnuoy/ceph-mon-6
num_units: 3 num_units: 3
options: options:
monitor-count: '3' monitor-count: '3'
source: cloud:bionic-train to:
- '3'
- '4'
- '5'
vault: vault:
series: bionic
num_units: 1 num_units: 1
# charm: cs:~openstack-charmers-next/vault # charm: cs:~openstack-charmers-next/vault
charm: cs:~gnuoy/vault-29 charm: cs:~gnuoy/vault-29
to:
- '6'
mysql: mysql:
series: bionic
charm: cs:~openstack-charmers-next/percona-cluster charm: cs:~openstack-charmers-next/percona-cluster
num_units: 1 num_units: 1
options: options:
innodb-buffer-pool-size: 256M innodb-buffer-pool-size: 256M
max-connections: 1000 max-connections: 1000
to:
- '7'
relations: relations:
- - ceph-mon:client - - ceph-mon:client
- ceph-iscsi:ceph-client - ceph-iscsi:ceph-client