commit bc273a59e149d94e600cb1a87c2b5b02cf3440f9 Author: Liam Young Date: Fri Jun 19 09:29:42 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: I2bd1062b6aa05eab4eb3bd8d602a2d02f085f531 diff --git a/charmhelpers/contrib/storage/linux/ceph.py b/charmhelpers/contrib/storage/linux/ceph.py index 526b95a..0f69631 100644 --- a/charmhelpers/contrib/storage/linux/ceph.py +++ b/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/charmhelpers/core/host_factory/ubuntu.py b/charmhelpers/core/host_factory/ubuntu.py index 3edc068..a3ec694 100644 --- a/charmhelpers/core/host_factory/ubuntu.py +++ b/charmhelpers/core/host_factory/ubuntu.py @@ -25,7 +25,8 @@ UBUNTU_RELEASES = ( 'cosmic', 'disco', 'eoan', - 'focal' + 'focal', + 'groovy' ) diff --git a/hooks/glance_relations.py b/hooks/glance_relations.py index 080137d..843b4aa 100755 --- a/hooks/glance_relations.py +++ b/hooks/glance_relations.py @@ -109,6 +109,7 @@ from charmhelpers.contrib.openstack.utils import ( is_db_maintenance_mode, ) from charmhelpers.contrib.storage.linux.ceph import ( + send_application_name, send_request_if_needed, is_request_complete, ensure_ceph_keyring, @@ -299,6 +300,7 @@ def object_store_joined(): @hooks.hook('ceph-relation-joined') def ceph_joined(): apt_install(['ceph-common']) + send_application_name() def get_ceph_request(): diff --git a/unit_tests/test_glance_relations.py b/unit_tests/test_glance_relations.py index 5e32910..71fa0e7 100644 --- a/unit_tests/test_glance_relations.py +++ b/unit_tests/test_glance_relations.py @@ -107,6 +107,7 @@ TO_PATCH = [ 'delete_keyring', 'get_relation_ip', 'is_db_maintenance_mode', + 'send_application_name', ] @@ -312,6 +313,7 @@ class GlanceRelationTests(CharmTestCase): def test_ceph_joined(self): relations.ceph_joined() self.apt_install.assert_called_with(['ceph-common']) + self.send_application_name.assert_called_with() @patch.object(relations, 'CONFIGS') def test_ceph_changed_missing_relation_data(self, configs):