From a3a618d733f73e31f7e35faef3ff49b060c2080c Mon Sep 17 00:00:00 2001 From: chris meyers Date: Wed, 28 Feb 2018 15:07:18 -0500 Subject: [PATCH 1/2] call node init procedures as early as possible * invoke the first heartbeat as early as possible. Results in a much better user experience where when a user scales up an awx node, the node appears with capacity earlier. --- awx/main/tasks.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/awx/main/tasks.py b/awx/main/tasks.py index 7bf41c515d..1421f2ed41 100644 --- a/awx/main/tasks.py +++ b/awx/main/tasks.py @@ -225,6 +225,10 @@ def handle_ha_toplogy_worker_ready(sender, **kwargs): logger.info("Workers on tower node '{}' unsubscribed from queues {} and subscribed to queues {}" .format(instance.hostname, removed_queues, added_queues)) + # Expedite the first hearbeat run so a node comes online quickly. + cluster_node_heartbeat.apply([]) + apply_cluster_membership_policies.apply([]) + @celeryd_init.connect def handle_update_celery_routes(sender=None, conf=None, **kwargs): From b69315f2eb88e92677c5fde69e3a313b1fc34393 Mon Sep 17 00:00:00 2001 From: chris meyers Date: Thu, 1 Mar 2018 15:17:15 -0500 Subject: [PATCH 2/2] fix up the config map watcher script * invoke main() in config watcher script * correctly call hash update by passing the filename --- tools/scripts/config-watcher | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/scripts/config-watcher b/tools/scripts/config-watcher index ffa2e56a1f..b608e7d8d9 100755 --- a/tools/scripts/config-watcher +++ b/tools/scripts/config-watcher @@ -25,6 +25,9 @@ def write_hash(f, h): def main(): + settings_file = "/etc/tower/settings.py" + hash_file = "/var/lib/awx/.configsha" + while 1: rpc = childutils.getRPCInterface(os.environ) headers, payload = childutils.listener.wait(sys.stdin, sys.stdout) @@ -32,13 +35,13 @@ def main(): childutils.listener.ok(sys.stdout) continue try: - current_hash = hash("/etc/tower/settings.py") + current_hash = hash(settings_file) except: sys.stderr.write("Could not open settings.py, skipping config watcher") childutils.listener.ok(sys.stdout) continue try: - if current_hash == last_hash("/var/lib/awx/.configsha"): + if current_hash == last_hash(hash_file): childutils.listener.ok(sys.stdout) continue else: @@ -51,8 +54,11 @@ def main(): sys.stderr.write('Restarting %s\n' % program) rpc.supervisor.stopProcess(program) rpc.supervisor.startProcess(program) - except: sys.stderr.write("No previous hash found") - write_hash("/var/lib/awx/.configsha") + + write_hash(hash_file, current_hash) childutils.listener.ok(sys.stdout) + +if __name__ == '__main__': + main()