mirror of
https://github.com/ansible/awx.git
synced 2026-03-03 09:48:51 -03:30
Merge pull request #1412 from chrismeyersfsu/reap_new_nodes_too
reap all nodes that havn't checked in
This commit is contained in:
@@ -346,14 +346,20 @@ def cluster_node_heartbeat(self):
|
|||||||
stop_local_services(['uwsgi', 'celery', 'beat', 'callback'], communicate=False)
|
stop_local_services(['uwsgi', 'celery', 'beat', 'callback'], communicate=False)
|
||||||
raise RuntimeError("Shutting down.")
|
raise RuntimeError("Shutting down.")
|
||||||
for other_inst in lost_instances:
|
for other_inst in lost_instances:
|
||||||
if other_inst.capacity == 0:
|
|
||||||
continue
|
|
||||||
try:
|
try:
|
||||||
other_inst.capacity = 0
|
# Capacity could already be 0 because:
|
||||||
other_inst.save(update_fields=['capacity'])
|
# * It's a new node and it never had a heartbeat
|
||||||
logger.error("Host {} last checked in at {}, marked as lost.".format(
|
# * It was set to 0 by another tower node running this method
|
||||||
other_inst.hostname, other_inst.modified))
|
# * It was set to 0 by this node, but auto deprovisioning is off
|
||||||
if settings.AWX_AUTO_DEPROVISION_INSTANCES:
|
#
|
||||||
|
# If auto deprovisining is on, don't bother setting the capacity to 0
|
||||||
|
# since we will delete the node anyway.
|
||||||
|
if other_inst.capacity != 0 and not settings.AWX_AUTO_DEPROVISION_INSTANCES:
|
||||||
|
other_inst.capacity = 0
|
||||||
|
other_inst.save(update_fields=['capacity'])
|
||||||
|
logger.error("Host {} last checked in at {}, marked as lost.".format(
|
||||||
|
other_inst.hostname, other_inst.modified))
|
||||||
|
elif settings.AWX_AUTO_DEPROVISION_INSTANCES:
|
||||||
deprovision_hostname = other_inst.hostname
|
deprovision_hostname = other_inst.hostname
|
||||||
other_inst.delete()
|
other_inst.delete()
|
||||||
logger.info("Host {} Automatically Deprovisioned.".format(deprovision_hostname))
|
logger.info("Host {} Automatically Deprovisioned.".format(deprovision_hostname))
|
||||||
|
|||||||
Reference in New Issue
Block a user