From 9c20b9412af61094d37a6e2d0cb6c9fc7a5d2ad3 Mon Sep 17 00:00:00 2001 From: chris meyers Date: Wed, 13 May 2020 08:30:39 -0400 Subject: [PATCH] delete and re-add host when ip address changes * The websocket backplane interconnect is done via ip address for Kubernetes and OpenShift. On init run_wsbroadcast reads all Instances from the DB and makes a decision to use the ip address or the hostname based, with preference given to the ip address if defined. For Kubernetes and OpenShift the nodes can load the Instance before the ip_address is set. This would cause the connection to be tried by hostname rather than ip address. This changeset ensures that an ip address set after an Instance record is created will be detected and used. --- awx/main/wsbroadcast.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/awx/main/wsbroadcast.py b/awx/main/wsbroadcast.py index 243981a885..05ab30602f 100644 --- a/awx/main/wsbroadcast.py +++ b/awx/main/wsbroadcast.py @@ -162,6 +162,13 @@ class BroadcastWebsocketManager(object): deleted_remote_hosts = set(current_remote_hosts) - set(future_remote_hosts) new_remote_hosts = set(future_remote_hosts) - set(current_remote_hosts) + remote_addresses = {k: v.remote_host for k, v in self.broadcast_tasks.items()} + for hostname, address in known_hosts.items(): + if hostname in self.broadcast_tasks and \ + address != remote_addresses[hostname]: + deleted_remote_hosts.add(hostname) + new_remote_hosts.add(hostname) + if deleted_remote_hosts: logger.warn(f"Removing {deleted_remote_hosts} from websocket broadcast list") if new_remote_hosts: