示例#1
0
    def test_mesos_sync_error(self, mock_dcos):
        """Tests doing a successful sync with mesos"""
        mock_dcos.return_value.json.return_value = {
            'slaves': [{
                'no_id_key': 'agent_1',
                'resources': {
                    'cpus': 1.0,
                    'mem': 1024.0,
                    'disk': 1024.0
                }
            }]
        }

        host = host_address_from_mesos_url('http://leader.mesos:80/mesos')
        resource_mgr.sync_with_mesos(host)
        self.assertEqual(resource_mgr._mesos_error,
                         'Missing key u\'id\' in mesos response')
示例#2
0
    def test_successful_mesos_sync(self, mock_dcos):
        """Tests doing a successful sync with mesos"""
        mock_dcos.return_value.json.return_value = {
            'slaves': [{
                'id': 'agent_1',
                'resources': {
                    'cpus': 1.0,
                    'mem': 1024.0,
                    'disk': 1024.0
                }
            }]
        }

        host = host_address_from_mesos_url('http://leader.mesos:80/mesos')
        resource_mgr.sync_with_mesos(host)
        self.assertTrue(
            resource_mgr._agent_resources['agent_1']._total_resources.is_equal(
                NodeResources([Cpus(1.0), Mem(1024.0),
                               Disk(1024.0)])))
示例#3
0
文件: sync.py 项目: Fizz11/scale
    def _execute(self):
        """See :meth:`scheduler.threads.base_thread.BaseSchedulerThread._execute`
        """

        scheduler_mgr.sync_with_database()
        job_type_mgr.sync_with_database()
        job_exe_mgr.sync_with_database()
        workspace_mgr.sync_with_database()

        node_mgr.sync_with_database(scheduler_mgr.config)
        cleanup_mgr.update_nodes(node_mgr.get_nodes())
        mesos_master = scheduler_mgr.mesos_address
        resource_mgr.sync_with_mesos(mesos_master.hostname, mesos_master.port)

        # Handle canceled job executions
        for finished_job_exe in job_exe_mgr.sync_with_database():
            cleanup_mgr.add_job_execution(finished_job_exe)

        if settings.SECRETS_URL:
            secrets_mgr.sync_with_backend()
示例#4
0
    def _execute(self):
        """See :meth:`scheduler.threads.base_thread.BaseSchedulerThread._execute`
        """

        scheduler_mgr.sync_with_database()
        job_type_mgr.sync_with_database()
        workspace_mgr.sync_with_database()

        node_mgr.sync_with_database(scheduler_mgr.config)
        cleanup_mgr.update_nodes(node_mgr.get_nodes())
        mesos_master = scheduler_mgr.mesos_address
        resource_mgr.sync_with_mesos(mesos_master.hostname, mesos_master.port)

        # Kill running tasks for canceled job executions
        for task_to_kill in job_exe_mgr.sync_with_database():
            pb_task_to_kill = mesos_pb2.TaskID()
            pb_task_to_kill.value = task_to_kill.id
            logger.info('Killing task %s', task_to_kill.id)
            self._driver.killTask(pb_task_to_kill)

        if settings.SECRETS_URL:
            secrets_mgr.sync_with_backend()