commit 5f6668d6f315607ebb9c6ab501948f4569a09fa0 Author: Liam Young Date: Fri Jun 19 09:27:20 2020 +0000 Send application name to ceph-mon Send application name to ceph-mon as ceph-mon cannot derive it from CMR relations. Change-Id: I0da4d7a55b1df947c10a8c7a4ae0f514c91be1eb diff --git a/hooks/charmhelpers/contrib/storage/linux/ceph.py b/hooks/charmhelpers/contrib/storage/linux/ceph.py index 526b95a..0f69631 100644 --- a/hooks/charmhelpers/contrib/storage/linux/ceph.py +++ b/hooks/charmhelpers/contrib/storage/linux/ceph.py @@ -41,6 +41,7 @@ from subprocess import ( ) from charmhelpers import deprecate from charmhelpers.core.hookenv import ( + application_name, config, service_name, local_unit, @@ -162,6 +163,17 @@ def get_osd_settings(relation_name): return _order_dict_by_key(osd_settings) +def send_application_name(relid=None): + """Send the application name down the relation. + + :param relid: Relation id to set application name in. + :type relid: str + """ + relation_set( + relation_id=relid, + relation_settings={'application-name': application_name()}) + + def send_osd_settings(): """Pass on requested OSD settings to osd units.""" try: @@ -1074,7 +1086,10 @@ def create_erasure_profile(service, profile_name, erasure_plugin_technique=None): """Create a new erasure code profile if one does not already exist for it. - Updates the profile if it exists. Please refer to [0] for more details. + Profiles are considered immutable so will not be updated if the named + profile already exists. + + Please refer to [0] for more details. 0: http://docs.ceph.com/docs/master/rados/operations/erasure-code-profile/ @@ -1110,6 +1125,11 @@ def create_erasure_profile(service, profile_name, :type erasure_plugin_technique: str :return: None. Can raise CalledProcessError, ValueError or AssertionError """ + if erasure_profile_exists(service, profile_name): + log('EC profile {} exists, skipping update'.format(profile_name), + level=WARNING) + return + plugin_techniques = { 'jerasure': [ 'reed_sol_van', @@ -1209,9 +1229,6 @@ def create_erasure_profile(service, profile_name, if scalar_mds: cmd.append('scalar-mds={}'.format(scalar_mds)) - if erasure_profile_exists(service, profile_name): - cmd.append('--force') - check_call(cmd) @@ -2198,6 +2215,7 @@ def send_request_if_needed(request, relation='ceph'): for rid in relation_ids(relation): log('Sending request {}'.format(request.request_id), level=DEBUG) relation_set(relation_id=rid, broker_req=request.request) + relation_set(relation_id=rid, relation_settings={'unit-name': local_unit()}) def has_broker_rsp(rid=None, unit=None): diff --git a/hooks/charmhelpers/core/host_factory/ubuntu.py b/hooks/charmhelpers/core/host_factory/ubuntu.py index 3edc068..a3ec694 100644 --- a/hooks/charmhelpers/core/host_factory/ubuntu.py +++ b/hooks/charmhelpers/core/host_factory/ubuntu.py @@ -25,7 +25,8 @@ UBUNTU_RELEASES = ( 'cosmic', 'disco', 'eoan', - 'focal' + 'focal', + 'groovy' ) diff --git a/hooks/nova_compute_hooks.py b/hooks/nova_compute_hooks.py index 0391728..83a06a8 100755 --- a/hooks/nova_compute_hooks.py +++ b/hooks/nova_compute_hooks.py @@ -84,6 +84,7 @@ from charmhelpers.contrib.storage.linux.ceph import ( get_broker_rsp_key, get_request_states, get_previous_request, + send_application_name, ) from charmhelpers.payload.execd import execd_preinstall from nova_compute_utils import ( @@ -383,6 +384,7 @@ def ceph_joined(): # Bug 1427660 if not is_unit_paused_set() and config('virt-type') in LIBVIRT_TYPES: service_restart(libvirt_daemon()) + send_application_name() def get_ceph_request(): diff --git a/unit_tests/test_nova_compute_hooks.py b/unit_tests/test_nova_compute_hooks.py index b20ea2c..2f39f34 100644 --- a/unit_tests/test_nova_compute_hooks.py +++ b/unit_tests/test_nova_compute_hooks.py @@ -98,6 +98,7 @@ TO_PATCH = [ 'render', 'remove_old_packages', 'services', + 'send_application_name', ] @@ -450,6 +451,7 @@ class NovaComputeRelationsTests(CharmTestCase): self.apt_install.assert_called_with(['ceph-common'], fatal=True) self.service_restart.assert_called_with('libvirt-bin') self.libvirt_daemon.assert_called() + self.send_application_name.assert_called_once_with() @patch.object(hooks, 'CONFIGS') def test_ceph_changed_missing_relation_data(self, configs):