Remove commented lines and add function to evalulate mds for juju status updates

This commit is contained in:
Chris Holcombe 2017-01-04 10:03:49 -08:00
parent 94c12d6fb3
commit 3e3552584c
2 changed files with 27 additions and 20 deletions

View File

@ -1,4 +1,3 @@
#
# Copyright 2012-2016 Canonical Ltd.
#
@ -657,7 +656,6 @@ def generate_monitor_secret():
return "{}==".format(res.split('=')[1].strip())
# OSD caps taken from ceph-create-keys
_osd_bootstrap_caps = {
'mon': [
@ -977,6 +975,16 @@ def filesystem_mounted(fs):
return subprocess.call(['grep', '-wqs', fs, '/proc/mounts']) == 0
def get_running_mds():
"""Returns a list of the pids of the current running MDS daemons"""
cmd = ['pgrep', 'ceph-mds']
try:
result = subprocess.check_output(cmd).decode('utf-8')
return result.split()
except subprocess.CalledProcessError:
return []
def get_running_osds():
"""Returns a list of the pids of the current running OSD daemons"""
cmd = ['pgrep', 'ceph-osd']

View File

@ -3,22 +3,17 @@ from charms.reactive import when, when_not, set_state, is_state
import charms.apt
from charms.ceph_base import (
# get_networks,
# get_public_addr,
get_peer_units,
get_mon_hosts,
is_bootstrapped,
is_quorum,
get_running_osds,
get_running_mds,
assert_charm_supports_ipv6
)
# from charmhelpers.core.host import (
# umount,
# )
from charmhelpers.core import hookenv
from charmhelpers.core.hookenv import (
# log,
config,
relation_ids,
related_units,
@ -53,22 +48,10 @@ def config_changed():
sysctl_dict = config('sysctl')
if sysctl_dict:
create_sysctl(sysctl_dict, '/etc/sysctl.d/50-ceph-charm.conf')
# if relations_of_type('nrpe-external-master'):
# update_nrpe_config()
# sysctl_dict = config('sysctl')
# if sysctl_dict:
# create_sysctl(sysctl_dict, '/etc/sysctl.d/50-ceph-osd-charm.conf')
# e_mountpoint = config('ephemeral-unmount')
# if e_mountpoint and ceph.filesystem_mounted(e_mountpoint):
# umount(e_mountpoint)
# prepare_disks_and_activate()
def assess_status():
'''Assess status of current unit'''
# is_state('ceph_mon.bootstrapped')
statuses = set([])
messages = set([])
if is_state('ceph_mon.installed'):
@ -79,6 +62,10 @@ def assess_status():
(status, message) = log_osds()
statuses.add(status)
messages.add(message)
if is_state('cephfs.started'):
(status, message) = log_mds()
statuses.add(status)
messages.add(message)
if 'blocked' in statuses:
status = 'blocked'
elif 'waiting' in statuses:
@ -149,6 +136,18 @@ def log_osds():
'Unit is ready ({} OSD)'.format(len(running_osds)))
def log_mds():
if len(relation_ids('mon')) < 1:
status_set('blocked', 'Missing relation: monitor')
return
running_mds = get_running_mds()
if not running_mds:
return ('blocked',
'No MDS detected using current configuration')
else:
return ('active',
'Unit is ready ({} MDS)'.format(len(running_mds)))
# Per https://github.com/juju-solutions/charms.reactive/issues/33,
# this module may be imported multiple times so ensure the
# initialization hook is only registered once. I have to piggy back