From 032949448fc6d1a472ff5d3040b0862b893c85d8 Mon Sep 17 00:00:00 2001 From: Nobuto Murata Date: Mon, 29 Jul 2024 22:36:14 +0900 Subject: [PATCH] Don't make any changes during update-status hooks Previously the config_changed function was invoked during the update-status hooks. And it made unnecessary changes to the system. Guard reactive functions properly. > INFO unit.ceph-fs/0.juju-log Invoking reactive handler: > reactive/ceph_fs.py:42:config_changed Closes-Bug: #2074349 Related-Bug: #2071780 Change-Id: If6cd061fef4c3625d6d498942949e31f243622df --- src/reactive/ceph_fs.py | 5 +++-- unit_tests/test_reactive_ceph_fs.py | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/reactive/ceph_fs.py b/src/reactive/ceph_fs.py index 2059a2d..e58b3e4 100644 --- a/src/reactive/ceph_fs.py +++ b/src/reactive/ceph_fs.py @@ -41,7 +41,7 @@ charm.use_defaults( ) -@reactive.when_none('charm.paused', 'run-default-update-status') +@reactive.when_none('charm.paused', 'is-update-status-hook') @reactive.when('ceph-mds.pools.available') def config_changed(): ceph_mds = reactive.endpoint_from_flag('ceph-mds.pools.available') @@ -77,6 +77,7 @@ def config_changed(): str(exc)) +@reactive.when_none('charm.paused', 'is-update-status-hook') @reactive.when('ceph-mds.connected') def storage_ceph_connected(ceph): ceph_mds = reactive.endpoint_from_flag('ceph-mds.connected') @@ -219,7 +220,7 @@ def storage_ceph_connected(ceph): ceph_mds.send_request_if_needed(rq) -@reactive.when_none('charm.paused', 'run-default-update-status') +@reactive.when_none('charm.paused', 'is-update-status-hook') @reactive.when('cephfs.configured', 'ceph-mds.pools.available', 'cephfs-share.available') def cephfs_share_available(): diff --git a/unit_tests/test_reactive_ceph_fs.py b/unit_tests/test_reactive_ceph_fs.py index 4a8fce1..e165d8f 100644 --- a/unit_tests/test_reactive_ceph_fs.py +++ b/unit_tests/test_reactive_ceph_fs.py @@ -47,11 +47,15 @@ class TestRegisteredHooks(test_utils.TestRegisteredHooks): 'when_none': { 'config_changed': ( 'charm.paused', - 'run-default-update-status', + 'is-update-status-hook', + ), + 'storage_ceph_connected': ( + 'charm.paused', + 'is-update-status-hook', ), 'cephfs_share_available': ( 'charm.paused', - 'run-default-update-status', + 'is-update-status-hook', ), }, }