Fix blocked gnocchi unit due to remove/add ceph-mon relation

Removing and adding back ceph-mon relation to gnocchi unit, the unit becomes
blocked. Since the flag ceph.create_pool.req.sent is already set, its not
triggered during subsequent add of ceph-mon relation. This makes the relation
inactive.

This patch resets the flag ceph.create_pool.req.sent based on the flags that
will be reset at ceph-client interface when relation is broken.

Change-Id: I3a1f4a0fa61c739c8e6d6581670438944dfcbc7c
Closes-Bug: #1856936
This commit is contained in:
Hemanth Nakkina 2019-12-20 14:53:37 +05:30
parent 6ef5cd0268
commit 901e08ea00
2 changed files with 15 additions and 0 deletions

View File

@ -111,3 +111,9 @@ def provide_gnocchi_url(metric_service):
hookenv.log("Providing gnocchi URL: {}"
.format(charm_class.public_url), hookenv.DEBUG)
metric_service.set_gnocchi_url(charm_class.public_url)
@reactive.when_not('storage-ceph.connected')
@reactive.when_not('storage-ceph.pools.available')
def reset_state_create_pool_req_sent():
reactive.remove_state('ceph.create_pool.req.sent')

View File

@ -80,6 +80,10 @@ class TestRegisteredHooks(test_utils.TestRegisteredHooks):
'check_ceph_request_status': (
'storage-ceph.pools.available',
),
'reset_state_create_pool_req_sent': (
'storage-ceph.connected',
'storage-ceph.pools.available',
),
},
}
# test that the hooks were registered via the
@ -160,3 +164,8 @@ class TestHandlers(test_utils.PatchHelper):
mock_gnocchi.set_gnocchi_url.assert_called_once_with(
"http://gnocchi:8041"
)
def test_reset_state_create_pool_req_sent(self):
self.patch_object(handlers.reactive, 'remove_state')
handlers.reset_state_create_pool_req_sent()
self.remove_state.assert_called_once_with('ceph.create_pool.req.sent')