From f737656b3217ba9a2ea864b974ffd88eaa34c0a4 Mon Sep 17 00:00:00 2001 From: David Ames Date: Wed, 7 Oct 2015 18:03:54 +0000 Subject: [PATCH 1/2] Run set_os_workload_status after every hook --- hooks/keystone_hooks.py | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/hooks/keystone_hooks.py b/hooks/keystone_hooks.py index 66e564d6..77c6d8a6 100755 --- a/hooks/keystone_hooks.py +++ b/hooks/keystone_hooks.py @@ -47,7 +47,7 @@ from charmhelpers.contrib.openstack.utils import ( git_install_requested, openstack_upgrade_available, sync_db_with_multi_ipv6_addresses, - os_workload_status, + set_os_workload_status, ) from keystone_utils import ( @@ -117,8 +117,6 @@ CONFIGS = register_configs() @hooks.hook('install.real') -@os_workload_status(CONFIGS, REQUIRED_INTERFACES, - charm_func=check_optional_relations) def install(): status_set('maintenance', 'Executing pre-install') execd_preinstall() @@ -132,8 +130,6 @@ def install(): @hooks.hook('config-changed') -@os_workload_status(CONFIGS, REQUIRED_INTERFACES, - charm_func=check_optional_relations) @restart_on_change(restart_map()) @synchronize_ca_if_changed(fatal=True) def config_changed(): @@ -210,8 +206,6 @@ def initialise_pki(): @hooks.hook('shared-db-relation-joined') -@os_workload_status(CONFIGS, REQUIRED_INTERFACES, - charm_func=check_optional_relations) def db_joined(): if is_relation_made('pgsql-db'): # error, postgresql is used @@ -230,8 +224,6 @@ def db_joined(): @hooks.hook('pgsql-db-relation-joined') -@os_workload_status(CONFIGS, REQUIRED_INTERFACES, - charm_func=check_optional_relations) def pgsql_db_joined(): if is_relation_made('shared-db'): # raise error @@ -270,8 +262,6 @@ def update_all_identity_relation_units_force_sync(): @hooks.hook('shared-db-relation-changed') -@os_workload_status(CONFIGS, REQUIRED_INTERFACES, - charm_func=check_optional_relations) @restart_on_change(restart_map()) @synchronize_ca_if_changed() def db_changed(): @@ -295,8 +285,6 @@ def db_changed(): @hooks.hook('pgsql-db-relation-changed') -@os_workload_status(CONFIGS, REQUIRED_INTERFACES, - charm_func=check_optional_relations) @restart_on_change(restart_map()) @synchronize_ca_if_changed() def pgsql_db_changed(): @@ -496,8 +484,6 @@ def leader_settings_changed(): @hooks.hook('ha-relation-joined') -@os_workload_status(CONFIGS, REQUIRED_INTERFACES, - charm_func=check_optional_relations) def ha_joined(relation_id=None): cluster_config = get_hacluster_config() resources = { @@ -559,8 +545,6 @@ def ha_joined(relation_id=None): @hooks.hook('ha-relation-changed') -@os_workload_status(CONFIGS, REQUIRED_INTERFACES, - charm_func=check_optional_relations) @restart_on_change(restart_map()) @synchronize_ca_if_changed() def ha_changed(): @@ -643,6 +627,8 @@ def update_nrpe_config(): def main(): try: hooks.execute(sys.argv) + set_os_workload_status(CONFIGS, REQUIRED_INTERFACES, + charm_func=check_optional_relations) except UnregisteredHookError as e: log('Unknown hook {} - skipping.'.format(e)) From 8f06087987a67db37147a3e8cf551f4c77763654 Mon Sep 17 00:00:00 2001 From: David Ames Date: Wed, 7 Oct 2015 20:46:49 +0000 Subject: [PATCH 2/2] Run even on unknown hook --- hooks/keystone_hooks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hooks/keystone_hooks.py b/hooks/keystone_hooks.py index 77c6d8a6..6fe5074e 100755 --- a/hooks/keystone_hooks.py +++ b/hooks/keystone_hooks.py @@ -627,10 +627,10 @@ def update_nrpe_config(): def main(): try: hooks.execute(sys.argv) - set_os_workload_status(CONFIGS, REQUIRED_INTERFACES, - charm_func=check_optional_relations) except UnregisteredHookError as e: log('Unknown hook {} - skipping.'.format(e)) + set_os_workload_status(CONFIGS, REQUIRED_INTERFACES, + charm_func=check_optional_relations) if __name__ == '__main__':