mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 05:29:26 -02:30
Address comments from @jjwatt
Signed-off-by: Rick Elrod <rick@elrod.me>
This commit is contained in:
committed by
John Westcott IV
parent
cd4d83acb7
commit
db71b63829
@@ -232,28 +232,20 @@ class WebSocketRelayManager(object):
|
|||||||
if payload.get("hostname") == self.local_hostname:
|
if payload.get("hostname") == self.local_hostname:
|
||||||
return
|
return
|
||||||
|
|
||||||
if payload.get("action") == "online":
|
action = payload.get("action")
|
||||||
|
|
||||||
|
if action in ("online", "offline"):
|
||||||
hostname = payload.get("hostname")
|
hostname = payload.get("hostname")
|
||||||
ip = payload.get("ip")
|
ip = payload.get("ip") or hostname # try back to hostname if ip isn't supplied
|
||||||
if ip is None:
|
if ip is None:
|
||||||
# If we don't get an IP, just try the hostname, maybe it resolves
|
logger.warning(f"Received invalid {action} ws_heartbeat, missing hostname and ip: {payload}")
|
||||||
ip = hostname
|
|
||||||
if ip is None:
|
|
||||||
logger.warning(f"Received invalid online ws_heartbeat, missing hostname and ip: {payload}")
|
|
||||||
return
|
return
|
||||||
|
logger.debug(f"Web host {hostname} ({ip}) {action} heartbeat received.")
|
||||||
|
|
||||||
|
if action == "online":
|
||||||
self.known_hosts[hostname] = ip
|
self.known_hosts[hostname] = ip
|
||||||
logger.debug(f"Web host {hostname} ({ip}) online heartbeat received.")
|
elif action == "offline":
|
||||||
elif payload.get("action") == "offline":
|
self.cleanup_offline_host(hostname)
|
||||||
hostname = payload.get("hostname")
|
|
||||||
ip = payload.get("ip")
|
|
||||||
if ip is None:
|
|
||||||
# If we don't get an IP, just try the hostname, maybe it resolves
|
|
||||||
ip = hostname
|
|
||||||
if ip is None:
|
|
||||||
logger.warning(f"Received invalid offline ws_heartbeat, missing hostname and ip: {payload}")
|
|
||||||
return
|
|
||||||
self.cleanup_offline_host(ip)
|
|
||||||
logger.debug(f"Web host {hostname} ({ip}) offline heartbeat received.")
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# This catch-all is the same as the one above. asyncio will eat the exception
|
# This catch-all is the same as the one above. asyncio will eat the exception
|
||||||
# but we want to know about it.
|
# but we want to know about it.
|
||||||
|
|||||||
Reference in New Issue
Block a user