Update hook to remove old ceph.conf alternatives
When adding ceph-mon relation to cinder, the charm installs ceph.conf with the update-alternatives via cinder_utils.resource_map(). However when the relation is removed, the alternative isn't cleaned up. This can cause issues if installing a cinder-ceph subordinate charm. The cinder-ceph charm also installs a ceph.conf alternative that will point to the leftover ceph.conf installed by the ceph-mon charm. Added remove_alternative() in ceph-relation-broken hook to ensure that leftover ceph.conf alternatives is removed upon relation removal. Change-Id: If9a8d460ee8209ef917fa55ec970379e9c741ec6 Related-Bug: 1778084
This commit is contained in:
parent
d3ca911e24
commit
e6a150c0d2
|
@ -39,6 +39,7 @@ from cinder_utils import (
|
|||
CLUSTER_RES,
|
||||
CINDER_CONF,
|
||||
CINDER_API_CONF,
|
||||
CEPH_CONF,
|
||||
setup_ipv6,
|
||||
check_local_db_actions_complete,
|
||||
filesystem_mounted,
|
||||
|
@ -92,6 +93,8 @@ from charmhelpers.contrib.openstack.utils import (
|
|||
series_upgrade_complete,
|
||||
)
|
||||
|
||||
from charmhelpers.contrib.openstack.alternatives import remove_alternative
|
||||
|
||||
from charmhelpers.contrib.storage.linux.ceph import (
|
||||
send_request_if_needed,
|
||||
is_request_complete,
|
||||
|
@ -435,6 +438,7 @@ def ceph_broken():
|
|||
service = service_name()
|
||||
delete_keyring(service=service)
|
||||
CONFIGS.write_all()
|
||||
remove_alternative(os.path.basename(CEPH_CONF), ceph_config_file())
|
||||
|
||||
|
||||
@hooks.hook('cluster-relation-joined')
|
||||
|
|
|
@ -37,6 +37,7 @@ from charmhelpers.core.hookenv import (
|
|||
related_units,
|
||||
log,
|
||||
DEBUG,
|
||||
hook_name,
|
||||
)
|
||||
|
||||
from charmhelpers.fetch import (
|
||||
|
@ -272,7 +273,7 @@ def resource_map(release=None):
|
|||
resource_map[CINDER_CONF]['services'].append('cinder-backup')
|
||||
resource_map[ceph_config_file()]['services'].append('cinder-backup')
|
||||
|
||||
if relation_ids('ceph'):
|
||||
if relation_ids('ceph') and hook_name() != 'ceph-relation-broken':
|
||||
# need to create this early, new peers will have a relation during
|
||||
# registration # before they've run the ceph hooks to create the
|
||||
# directory.
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import os
|
||||
import json
|
||||
|
||||
from six.moves import reload_module
|
||||
|
@ -57,6 +58,7 @@ TO_PATCH = [
|
|||
'service_enabled',
|
||||
'CONFIGS',
|
||||
'CLUSTER_RES',
|
||||
'CEPH_CONF',
|
||||
'ceph_config_file',
|
||||
'update_nrpe_config',
|
||||
'remove_old_packages',
|
||||
|
@ -87,6 +89,7 @@ TO_PATCH = [
|
|||
'execd_preinstall',
|
||||
'sync_db_with_multi_ipv6_addresses',
|
||||
'delete_keyring',
|
||||
'remove_alternative',
|
||||
'get_relation_ip',
|
||||
'services',
|
||||
]
|
||||
|
@ -579,6 +582,9 @@ class TestJoinedHooks(CharmTestCase):
|
|||
hooks.hooks.execute(['hooks/ceph-relation-broken'])
|
||||
self.delete_keyring.assert_called_with(service='cinder')
|
||||
self.assertTrue(self.CONFIGS.write_all.called)
|
||||
self.remove_alternative.assert_called_with(
|
||||
os.path.basename(self.CEPH_CONF),
|
||||
self.ceph_config_file())
|
||||
|
||||
def test_ceph_changed_no_leadership(self):
|
||||
'''It does not attempt to create ceph pool if not leader'''
|
||||
|
|
Loading…
Reference in New Issue