From 901e08ea003a6e6e5915fac53afe2dc9f244c8e3 Mon Sep 17 00:00:00 2001 From: Hemanth Nakkina Date: Fri, 20 Dec 2019 14:53:37 +0530 Subject: [PATCH] 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 --- src/reactive/gnocchi_handlers.py | 6 ++++++ unit_tests/test_gnocchi_handlers.py | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/src/reactive/gnocchi_handlers.py b/src/reactive/gnocchi_handlers.py index ac0c9ed..5de135f 100644 --- a/src/reactive/gnocchi_handlers.py +++ b/src/reactive/gnocchi_handlers.py @@ -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') diff --git a/unit_tests/test_gnocchi_handlers.py b/unit_tests/test_gnocchi_handlers.py index fe971de..5be6efe 100644 --- a/unit_tests/test_gnocchi_handlers.py +++ b/unit_tests/test_gnocchi_handlers.py @@ -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')