def osd_relation(relid=None, unit=None): if ceph.is_quorum(): log('mon cluster in quorum - providing fsid & keys') public_addr = get_public_addr() data = { 'fsid': leader_get('fsid'), 'osd_bootstrap_key': ceph.get_osd_bootstrap_key(), 'auth': config('auth-supported'), 'ceph-public-address': public_addr, 'osd_upgrade_key': ceph.get_named_key('osd-upgrade', caps=ceph.osd_upgrade_caps), } data.update(handle_broker_request(relid, unit)) relation_set(relation_id=relid, relation_settings=data) if is_leader(): ceph_osd_releases = get_ceph_osd_releases() if len(ceph_osd_releases) == 1: execute_post_osd_upgrade_steps(ceph_osd_releases[0]) # NOTE: radosgw key provision is gated on presence of OSD # units so ensure that any deferred hooks are processed notify_radosgws() notify_client() notify_rbd_mirrors() send_osd_settings() else: log('mon cluster not in quorum - deferring fsid provision')
def admin_relation_joined(relid=None): if ceph.is_quorum(): name = relation_get('keyring-name') if name is None: name = 'admin' log('mon cluster in quorum - providing admin client with keys') mon_hosts = config('monitor-hosts') or ' '.join(get_mon_hosts()) data = { 'key': ceph.get_named_key(name=name, caps=ceph.admin_caps), 'fsid': leader_get('fsid'), 'auth': config('auth-supported'), 'mon_hosts': mon_hosts, } relation_set(relation_id=relid, relation_settings=data)
def ready_for_service(): ''' Determine whether the Ceph cluster is ready to service storage traffic from clients @return: boolean indicating whether the Ceph cluster is ready for pool creation/client usage. ''' if not ceph.is_quorum(): log('mon cluster is not in quorum', level=DEBUG) return False if not sufficient_osds(config('expected-osd-count') or 3): log('insufficient osds bootstrapped', level=DEBUG) return False return True
def assess_status(): '''Assess status of current unit''' application_version_set(get_upstream_version(VERSION_PACKAGE)) if not config('permit-insecure-cmr'): units = [ unit for rtype in relations() for relid in relation_ids(reltype=rtype) for unit in related_units(relid=relid) if is_cmr_unit(unit) ] if units: status_set("blocked", "Unsupported CMR relation") return if is_unit_upgrading_set(): status_set( "blocked", "Ready for do-release-upgrade and reboot. " "Set complete when finished.") return # Check that the no-bootstrap config option is set in conjunction with # having the bootstrap-source relation established if not config('no-bootstrap') and is_relation_made('bootstrap-source'): status_set( 'blocked', 'Cannot join the bootstrap-source relation when ' 'no-bootstrap is False') return moncount = int(config('monitor-count')) units = get_peer_units() # not enough peers and mon_count > 1 if len(units.keys()) < moncount: status_set( 'blocked', 'Insufficient peer units to bootstrap' ' cluster (require {})'.format(moncount)) return # mon_count > 1, peers, but no ceph-public-address ready = sum(1 for unit_ready in units.values() if unit_ready) if ready < moncount: status_set('waiting', 'Peer units detected, waiting for addresses') return configured_rbd_features = config('default-rbd-features') if has_rbd_mirrors() and configured_rbd_features: if add_rbd_mirror_features( configured_rbd_features) != configured_rbd_features: # The configured RBD features bitmap does not contain the features # required for RBD Mirroring status_set( 'blocked', 'Configuration mismatch: RBD Mirroring ' 'enabled but incorrect value set for ' '``default-rbd-features``') return try: get_osd_settings('client') except OSD_SETTING_EXCEPTIONS as e: status_set('blocked', str(e)) return # active - bootstrapped + quorum status check if ceph.is_bootstrapped() and ceph.is_quorum(): expected_osd_count = config('expected-osd-count') or 3 if sufficient_osds(expected_osd_count): status_set('active', 'Unit is ready and clustered') else: status_set( 'waiting', 'Monitor bootstrapped but waiting for number of' ' OSDs to reach expected-osd-count ({})'.format( expected_osd_count)) else: # Unit should be running and clustered, but no quorum # TODO: should this be blocked or waiting? status_set('blocked', 'Unit not clustered (no quorum)')