Esempio n. 1
0
    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_cpu']:
                logger.warning('Isolated instance {} has re-joined.'.format(
                    instance.hostname))
            instance.cpu_capacity = int(task_result['capacity_cpu'])
            instance.mem_capacity = int(task_result['capacity_mem'])
            instance.capacity = get_system_task_capacity(
                scale=instance.capacity_adjustment,
                cpu_capacity=int(task_result['capacity_cpu']),
                mem_capacity=int(task_result['capacity_mem']))
        instance.save(update_fields=[
            'cpu_capacity', 'mem_capacity', 'capacity', 'version', 'modified'
        ])
Esempio n. 2
0
    def refresh_capacity(self):
        if settings.IS_K8S:
            self.capacity = self.cpu = self.memory = self.cpu_capacity = self.mem_capacity = 0  # noqa
            self.version = awx_application_version
            self.save(update_fields=[
                'capacity', 'version', 'modified', 'cpu', 'memory',
                'cpu_capacity', 'mem_capacity'
            ])
            return

        cpu = get_cpu_capacity()
        mem = get_mem_capacity()
        if self.enabled:
            self.capacity = get_system_task_capacity(self.capacity_adjustment)
        else:
            self.capacity = 0

        try:
            # if redis is down for some reason, that means we can't persist
            # playbook event data; we should consider this a zero capacity event
            redis.Redis.from_url(settings.BROKER_URL).ping()
        except redis.ConnectionError:
            self.capacity = 0

        self.cpu = cpu[0]
        self.memory = mem[0]
        self.cpu_capacity = cpu[1]
        self.mem_capacity = mem[1]
        self.version = awx_application_version
        self.save(update_fields=[
            'capacity', 'version', 'modified', 'cpu', 'memory', 'cpu_capacity',
            'mem_capacity'
        ])
Esempio n. 3
0
File: manager.py Progetto: vzer/awx
    def update_capacity(cls, instance, task_result):
        instance.version = 'ansible-runner-{}'.format(task_result['version'])

        if instance.capacity == 0 and task_result['capacity_cpu']:
            logger.warning('Isolated instance {} has re-joined.'.format(instance.hostname))
        instance.cpu_capacity = int(task_result['capacity_cpu'])
        instance.mem_capacity = int(task_result['capacity_mem'])
        instance.capacity = get_system_task_capacity(scale=instance.capacity_adjustment,
                                                     cpu_capacity=int(task_result['capacity_cpu']),
                                                     mem_capacity=int(task_result['capacity_mem']))
        instance.save(update_fields=['cpu_capacity', 'mem_capacity', 'capacity', 'version', 'modified'])
Esempio n. 4
0
File: ha.py Progetto: weicq/awx
 def refresh_capacity(self):
     cpu = get_cpu_capacity()
     mem = get_mem_capacity()
     self.capacity = get_system_task_capacity(self.capacity_adjustment)
     self.cpu = cpu[0]
     self.memory = mem[0]
     self.cpu_capacity = cpu[1]
     self.mem_capacity = mem[1]
     self.version = awx_application_version
     self.save(update_fields=['capacity', 'version', 'modified', 'cpu',
                              'memory', 'cpu_capacity', 'mem_capacity'])