diff --git a/hooks/ceph_hooks.py b/hooks/ceph_hooks.py index 351d7d51..7d33f45a 100755 --- a/hooks/ceph_hooks.py +++ b/hooks/ceph_hooks.py @@ -80,6 +80,7 @@ from utils import ( import_osd_bootstrap_key, import_osd_upgrade_key, import_osd_removal_key, + import_client_crash_key, get_host_ip, get_networks, assert_charm_supports_ipv6, @@ -653,6 +654,7 @@ def mon_relation(): bootstrap_key = relation_get('osd_bootstrap_key') upgrade_key = relation_get('osd_upgrade_key') removal_key = relation_get('osd_disk_removal_key') + client_crash_key = relation_get('client_crash_key') if get_fsid() and get_auth() and bootstrap_key: log('mon has provided conf- scanning disks') emit_cephconf() @@ -664,6 +666,8 @@ def mon_relation(): _, settings, _ = (ch_ceph.CephOSDConfContext() .filter_osd_from_mon_settings()) ceph.apply_osd_settings(settings) + if client_crash_key: + import_client_crash_key(client_crash_key) else: log('mon cluster has not yet provided conf') diff --git a/hooks/utils.py b/hooks/utils.py index 44f96c62..0a14d1bb 100644 --- a/hooks/utils.py +++ b/hooks/utils.py @@ -73,6 +73,7 @@ except ImportError: _bootstrap_keyring = "/var/lib/ceph/bootstrap-osd/ceph.keyring" _upgrade_keyring = "/var/lib/ceph/osd/ceph.client.osd-upgrade.keyring" _removal_keyring = "/var/lib/ceph/osd/ceph.client.osd-removal.keyring" +_client_crash_keyring = "/var/lib/ceph/osd/ceph.client.crash.keyring" def is_osd_bootstrap_ready(): @@ -129,6 +130,16 @@ def import_osd_removal_key(key): _import_key(key, _removal_keyring, 'client.osd-removal') +def import_client_crash_key(key): + """ + Ensure that the client.crash keyring is set up. + + :param key: The cephx key to add to the client.crash keyring + :type key: str + :raises: subprocess.CalledProcessError""" + _import_key(key, _client_crash_keyring, 'client.crash') + + def render_template(template_name, context, template_dir=TEMPLATES_DIR): """Render Jinja2 template. diff --git a/lib/charms_ceph/utils.py b/lib/charms_ceph/utils.py index a22462ec..3633dd4c 100644 --- a/lib/charms_ceph/utils.py +++ b/lib/charms_ceph/utils.py @@ -695,7 +695,7 @@ def get_local_osd_ids(): try: dirs = os.listdir(osd_path) for osd_dir in dirs: - osd_id = osd_dir.split('-')[1] + osd_id = osd_dir.split('-')[1] if '-' in osd_dir else '' if (_is_int(osd_id) and filesystem_mounted(os.path.join( os.sep, osd_path, osd_dir))): diff --git a/templates/ceph.conf b/templates/ceph.conf index 782a231d..2966ce58 100644 --- a/templates/ceph.conf +++ b/templates/ceph.conf @@ -54,6 +54,9 @@ keyring = /var/lib/ceph/osd/ceph.client.osd-upgrade.keyring [client.osd-removal] keyring = /var/lib/ceph/osd/ceph.client.osd-removal.keyring +[client.crash] +keyring = /var/lib/ceph/osd/ceph.client.crash.keyring + [mon] keyring = /var/lib/ceph/mon/$cluster-$id/keyring