From f9b2eb310e78cdc5a8ae9461a5bf7124c5bb95d7 Mon Sep 17 00:00:00 2001 From: Jorge Niedbalski Date: Fri, 15 Sep 2017 17:17:58 -0300 Subject: [PATCH] Remove update_clients() call from update-status. The commit [0] added a explicit call to update_clients which is executed on every hook run (including update-status), the update_clients function iterates over all the units related through the amqp relation and makes a call to the amqp_changed function. As the update_status hook interval is set to run every 5 minutes, isn't convenient to do a call to amqp_changed for every related unit particularly in large scale deployments, as this might cause an unwanted workload overhead on the cloud at every tick of the update-status hook. Further work needs to be done to improve the overall handling performed via the update_clients function but this commit alleviates the problem of leaving the update-status hook stuck for ~1 hour every time. [0] 2472e1ca9fbd68cdd50640eadd071177ddc5968e Change-Id: If9d6ed03d0b8a79fa0210fba57a3d54c2646214d Closes-Bug: #1717579 Signed-off-by: Jorge Niedbalski --- hooks/rabbitmq_server_relations.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/hooks/rabbitmq_server_relations.py b/hooks/rabbitmq_server_relations.py index ae7b45dc..691d4830 100755 --- a/hooks/rabbitmq_server_relations.py +++ b/hooks/rabbitmq_server_relations.py @@ -121,7 +121,7 @@ def install(): def validate_amqp_config_tracker(f): """Decorator to mark all existing tracked amqp configs as stale so that - they are refreshed the next time the current unit leader. + they are refreshed the next time the current unit leader. """ def _validate_amqp_config_tracker(*args, **kwargs): if not is_leader(): @@ -677,7 +677,7 @@ def config_changed(): '/etc/default/rabbitmq-server') # Install packages to ensure any changes to source - # result in an upgrade if applicable only if we change the 'source' + # result in an upgrade if applicable only if we change the 'source' # config option if rabbit.archive_upgrade_available(): rabbit.install_or_upgrade_packages() @@ -782,6 +782,16 @@ if __name__ == '__main__': hooks.execute(sys.argv) except UnregisteredHookError as e: log('Unknown hook {} - skipping.'.format(e)) - # Gated client updates - update_clients() + + # NOTE(niedbalski): we skip running update_clients on + # update-status as this might workload overhead on the + # cloud at every tick of the update-status hook. (LP:#1717579). + (hook, skip) = (os.path.basename(sys.argv[0]), ('update-status', )) + if hook in skip: + log("Skipping to run update_clients on hook: {} - skip: {}".format( + hook, ",".join(skip)), DEBUG) + else: + # Gated client updates + update_clients() + rabbit.assess_status(rabbit.ConfigRenderer(rabbit.CONFIG_FILES))