mirror of
https://github.com/ansible/awx.git
synced 2026-03-15 07:57:29 -02:30
Set capacity to zero if the isolated node has an old version
This commit is contained in:
committed by
Matthew Jones
parent
06210624ce
commit
692007072d
@@ -9,6 +9,7 @@ import stat
|
|||||||
import tempfile
|
import tempfile
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
|
from distutils.version import LooseVersion as Version
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
@@ -370,7 +371,24 @@ class IsolatedManager(object):
|
|||||||
logger.warning('Isolated job {} cleanup error, output:\n{}'.format(self.instance.id, output))
|
logger.warning('Isolated job {} cleanup error, output:\n{}'.format(self.instance.id, output))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def health_check(cls, instance_qs):
|
def update_capacity(cls, instance, task_result, awx_application_version):
|
||||||
|
instance.version = task_result['version']
|
||||||
|
|
||||||
|
isolated_version = instance.version.split("-", 1)[0]
|
||||||
|
cluster_version = awx_application_version.split("-", 1)[0]
|
||||||
|
|
||||||
|
if Version(cluster_version) > Version(isolated_version):
|
||||||
|
err_template = "Isolated instance {} reports version {}, cluster node is at {}, setting capacity to zero."
|
||||||
|
logger.error(err_template.format(instance.hostname, instance.version, awx_application_version))
|
||||||
|
instance.capacity = 0
|
||||||
|
else:
|
||||||
|
if instance.capacity == 0 and task_result['capacity']:
|
||||||
|
logger.warning('Isolated instance {} has re-joined.'.format(instance.hostname))
|
||||||
|
instance.capacity = int(task_result['capacity'])
|
||||||
|
instance.save(update_fields=['capacity', 'version', 'modified'])
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def health_check(cls, instance_qs, awx_application_version):
|
||||||
'''
|
'''
|
||||||
:param instance_qs: List of Django objects representing the
|
:param instance_qs: List of Django objects representing the
|
||||||
isolated instances to manage
|
isolated instances to manage
|
||||||
@@ -412,11 +430,7 @@ class IsolatedManager(object):
|
|||||||
except (KeyError, IndexError):
|
except (KeyError, IndexError):
|
||||||
task_result = {}
|
task_result = {}
|
||||||
if 'capacity' in task_result:
|
if 'capacity' in task_result:
|
||||||
instance.version = task_result['version']
|
cls.update_capacity(instance, awx_application_version)
|
||||||
if instance.capacity == 0 and task_result['capacity']:
|
|
||||||
logger.warning('Isolated instance {} has re-joined.'.format(instance.hostname))
|
|
||||||
instance.capacity = int(task_result['capacity'])
|
|
||||||
instance.save(update_fields=['capacity', 'version', 'modified'])
|
|
||||||
elif instance.capacity == 0:
|
elif instance.capacity == 0:
|
||||||
logger.debug('Isolated instance {} previously marked as lost, could not re-join.'.format(
|
logger.debug('Isolated instance {} previously marked as lost, could not re-join.'.format(
|
||||||
instance.hostname))
|
instance.hostname))
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ def awx_isolated_heartbeat(self):
|
|||||||
# Slow pass looping over isolated IGs and their isolated instances
|
# Slow pass looping over isolated IGs and their isolated instances
|
||||||
if len(isolated_instance_qs) > 0:
|
if len(isolated_instance_qs) > 0:
|
||||||
logger.debug("Managing isolated instances {}.".format(','.join([inst.hostname for inst in isolated_instance_qs])))
|
logger.debug("Managing isolated instances {}.".format(','.join([inst.hostname for inst in isolated_instance_qs])))
|
||||||
isolated_manager.IsolatedManager.health_check(isolated_instance_qs)
|
isolated_manager.IsolatedManager.health_check(isolated_instance_qs, awx_application_version)
|
||||||
|
|
||||||
|
|
||||||
@task(bind=True, queue='tower', base=LogErrorsTask)
|
@task(bind=True, queue='tower', base=LogErrorsTask)
|
||||||
|
|||||||
Reference in New Issue
Block a user