Clean up stale ceph keyring
[cbjchen,r=] Clean up the keyring after ceph relation is broken. So when next time ceph relation is joined, ensure_ceph_keyring will not ignore the new key because of the existance of the old one.
This commit is contained in:
parent
8b28d7c956
commit
efb28d7d42
@ -58,6 +58,7 @@ from charmhelpers.contrib.storage.linux.ceph import (
|
||||
ensure_ceph_keyring,
|
||||
CephBrokerRq,
|
||||
CephBrokerRsp,
|
||||
delete_keyring,
|
||||
)
|
||||
|
||||
from charmhelpers.contrib.hahelpers.cluster import (
|
||||
@ -300,6 +301,13 @@ def ceph_changed(relation_id=None):
|
||||
log("Request(s) sent to Ceph broker (rid=%s)" % (rid))
|
||||
|
||||
|
||||
@hooks.hook('ceph-relation-broken')
|
||||
def ceph_broken():
|
||||
service = service_name()
|
||||
delete_keyring(service=service)
|
||||
CONFIGS.write_all()
|
||||
|
||||
|
||||
@hooks.hook('cluster-relation-joined')
|
||||
def cluster_joined(relation_id=None):
|
||||
for addr_type in ADDRESS_TYPES:
|
||||
@ -400,7 +408,6 @@ def image_service_changed():
|
||||
|
||||
|
||||
@hooks.hook('amqp-relation-broken',
|
||||
'ceph-relation-broken',
|
||||
'identity-service-relation-broken',
|
||||
'image-service-relation-broken',
|
||||
'shared-db-relation-broken',
|
||||
|
@ -68,7 +68,8 @@ TO_PATCH = [
|
||||
'get_hacluster_config',
|
||||
'execd_preinstall',
|
||||
'get_ipv6_addr',
|
||||
'sync_db_with_multi_ipv6_addresses'
|
||||
'sync_db_with_multi_ipv6_addresses',
|
||||
'delete_keyring'
|
||||
]
|
||||
|
||||
|
||||
@ -435,6 +436,12 @@ class TestJoinedHooks(CharmTestCase):
|
||||
self.assertTrue(self.juju_log.called)
|
||||
self.assertFalse(self.CONFIGS.write.called)
|
||||
|
||||
def test_ceph_broken(self):
|
||||
self.service_name.return_value = 'cinder'
|
||||
hooks.hooks.execute(['hooks/ceph-relation-broken'])
|
||||
self.delete_keyring.assert_called_with(service='cinder')
|
||||
self.assertTrue(self.CONFIGS.write_all.called)
|
||||
|
||||
def test_ceph_changed_no_leadership(self):
|
||||
'''It does not attempt to create ceph pool if not leader'''
|
||||
self.eligible_leader.return_value = False
|
||||
|
Loading…
x
Reference in New Issue
Block a user