예제 #1
0
파일: manager.py 프로젝트: ctc-oss/scale
    def sync_with_mesos(self, master_hostname, master_port):
        """Syncs with Mesos to retrieve the resouce totals needed by any agents

        :param master_hostname: The name of the Mesos master host
        :type master_hostname: string
        :param master_port: The port used by the Mesos master
        :type master_port: int
        """

        agents_needing_totals = set()
        with self._agent_resources_lock:
            for agent_resources in self._agent_resources.values():
                if not agent_resources.has_total_resources():
                    agents_needing_totals.add(agent_resources.agent_id)

        resources = {}
        try:
            resources = get_agent_resources(master_hostname, master_port,
                                            agents_needing_totals)
        except:
            logger.exception('Error getting agent resource totals from Mesos')

        with self._agent_resources_lock:
            for agent_id in resources:
                self._agent_resources[agent_id].set_total(resources[agent_id])
예제 #2
0
    def sync_with_mesos(self, host_address):
        """Syncs with Mesos to retrieve the resource totals needed by any agents

        :param host_address: The address for the Mesos master
        :type host_address: `util.host.HostAddress`
        """

        agents_needing_totals = set()
        with self._agent_resources_lock:
            for agent_resources in self._agent_resources.values():
                if not agent_resources.has_total_resources():
                    agents_needing_totals.add(agent_resources.agent_id)

        resources = {}
        try:
            resources = get_agent_resources(host_address,
                                            agents_needing_totals)
        except KeyError as ex:
            if not self._mesos_error:
                self._mesos_error_started = datetime.datetime.now()
            logger.exception(
                'Error getting agent resource totals from Mesos: missing key %s'
                % ex)
            self._mesos_error = 'Missing key %s in mesos response' % ex
        except Exception as ex:
            if not self._mesos_error:
                self._mesos_error_started = datetime.datetime.now()
            logger.exception(
                'Error getting agent resource totals from Mesos: %s' % ex)
            self._mesos_error = str(ex)

        if resources:
            #clear error
            logger.info('Received resources again from mesos')
            self._mesos_error = None
            self._mesos_error_started = None

        if self._mesos_error_started and datetime.datetime.now(
        ) > self._mesos_error_started + SHUTDOWN_PERIOD:
            from scheduler.management.commands.scale_scheduler import GLOBAL_SHUTDOWN
            logger.info('Shutting down due to lack of resources from mesos')
            GLOBAL_SHUTDOWN()

        with self._agent_resources_lock:
            for agent_id in resources:
                self._agent_resources[agent_id].set_total(resources[agent_id])
예제 #3
0
파일: manager.py 프로젝트: sau29/scale
    def sync_with_mesos(self, host_address):
        """Syncs with Mesos to retrieve the resource totals needed by any agents

        :param host_address: The address for the Mesos master
        :type host_address: `util.host.HostAddress`
        """

        agents_needing_totals = set()
        with self._agent_resources_lock:
            for agent_resources in self._agent_resources.values():
                if not agent_resources.has_total_resources():
                    agents_needing_totals.add(agent_resources.agent_id)

        resources = {}
        try:
            resources = get_agent_resources(host_address,
                                            agents_needing_totals)
        except:
            logger.exception('Error getting agent resource totals from Mesos')

        with self._agent_resources_lock:
            for agent_id in resources:
                self._agent_resources[agent_id].set_total(resources[agent_id])