Example #1
0
    def test_touch_conductor(self, mock_utcnow):
        test_time = datetime.datetime(2000, 1, 1, 0, 0)
        mock_utcnow.return_value = test_time
        c = self._create_test_cdr(updated_at=test_time)
        self.assertEqual(test_time, timeutils.normalize_time(c.updated_at))

        test_time = datetime.datetime(2000, 1, 1, 0, 1)
        mock_utcnow.return_value = test_time
        self.dbapi.touch_conductor(c.hostname)
        c = self.dbapi.get_conductor(c.hostname)
        self.assertEqual(test_time, timeutils.normalize_time(c.updated_at))
Example #2
0
    def test_touch_conductor(self):
        t = datetime.datetime(2000, 1, 1, 0, 0)
        timeutils.set_time_override(override_time=t)
        c = self._create_test_cdr(updated_at=t)
        self.assertEqual(t, timeutils.normalize_time(c['updated_at']))

        t = datetime.datetime(2000, 1, 1, 0, 1)
        timeutils.set_time_override(override_time=t)
        self.dbapi.touch_conductor(c['hostname'])
        c = self.dbapi.get_conductor(c['hostname'])
        self.assertEqual(t, timeutils.normalize_time(c['updated_at']))
Example #3
0
    def test_touch_conductor(self, mock_utcnow):
        test_time = datetime.datetime(2000, 1, 1, 0, 0)
        mock_utcnow.return_value = test_time
        c = self._create_test_cdr(updated_at=test_time)
        self.assertEqual(test_time, timeutils.normalize_time(c.updated_at))

        test_time = datetime.datetime(2000, 1, 1, 0, 1)
        mock_utcnow.return_value = test_time
        self.dbapi.touch_conductor(c.hostname)
        c = self.dbapi.get_conductor(c.hostname)
        self.assertEqual(test_time, timeutils.normalize_time(c.updated_at))
Example #4
0
 def test_update_node_provision(self, mock_utcnow):
     mocked_time = datetime.datetime(2000, 1, 1, 0, 0)
     mock_utcnow.return_value = mocked_time
     n = self._create_test_node()
     res = self.dbapi.update_node(n['id'], {'provision_state': 'fake'})
     self.assertEqual(mocked_time,
                      timeutils.normalize_time(res['provision_updated_at']))
Example #5
0
 def test_update_node_provision(self, mock_utcnow):
     mocked_time = datetime.datetime(2000, 1, 1, 0, 0)
     mock_utcnow.return_value = mocked_time
     n = self._create_test_node()
     res = self.dbapi.update_node(n['id'], {'provision_state': 'fake'})
     self.assertEqual(mocked_time,
                      timeutils.normalize_time(res['provision_updated_at']))
Example #6
0
    def _check_deploy_timeouts(self, context):
        if not CONF.conductor.deploy_callback_timeout:
            return

        filters = {'reserved': False, 'maintenance': False}
        columns = ['uuid', 'driver', 'provision_state', 'provision_updated_at']
        node_list = self.dbapi.get_nodeinfo_list(columns=columns,
                                                 filters=filters)

        for (node_uuid, driver, state, update_time) in node_list:
            mapped_hosts = self.driver_rings[driver].get_hosts(node_uuid)
            if self.host not in mapped_hosts:
                continue

            if state == states.DEPLOYWAIT:
                limit = (timeutils.utcnow() - datetime.timedelta(
                         seconds=CONF.conductor.deploy_callback_timeout))
                if timeutils.normalize_time(update_time) <= limit:
                    try:
                        task = task_manager.TaskManager(context, node_uuid)
                    except (exception.NodeLocked, exception.NodeNotFound):
                        continue

                    node = task.node
                    node.provision_state = states.DEPLOYFAIL
                    node.target_provision_state = states.NOSTATE
                    msg = (_('Timeout reached when waiting callback for '
                             'node %s') % node_uuid)
                    node.last_error = msg
                    LOG.error(msg)
                    node.save(task.context)

                    try:
                        thread = self._spawn_worker(
                                            utils.cleanup_after_timeout, task)
                        thread.link(lambda t: task.release_resources())
                    except exception.NoFreeConductorWorker:
                        task.release_resources()
Example #7
0
    def _check_deploy_timeouts(self, context):
        if not CONF.conductor.deploy_callback_timeout:
            return

        filters = {'reserved': False, 'maintenance': False}
        columns = ['uuid', 'driver', 'provision_state', 'provision_updated_at']
        node_list = self.dbapi.get_nodeinfo_list(columns=columns,
                                                 filters=filters)

        for (node_uuid, driver, state, update_time) in node_list:
            mapped_hosts = self.driver_rings[driver].get_hosts(node_uuid)
            if self.host not in mapped_hosts:
                continue

            if state == states.DEPLOYWAIT:
                limit = (timeutils.utcnow() - datetime.timedelta(
                    seconds=CONF.conductor.deploy_callback_timeout))
                if timeutils.normalize_time(update_time) <= limit:
                    try:
                        task = task_manager.TaskManager(context, node_uuid)
                    except (exception.NodeLocked, exception.NodeNotFound):
                        continue

                    node = task.node
                    node.provision_state = states.DEPLOYFAIL
                    node.target_provision_state = states.NOSTATE
                    msg = (_('Timeout reached when waiting callback for '
                             'node %s') % node_uuid)
                    node.last_error = msg
                    LOG.error(msg)
                    node.save(task.context)

                    try:
                        thread = self._spawn_worker(
                            utils.cleanup_after_timeout, task)
                        thread.link(lambda t: task.release_resources())
                    except exception.NoFreeConductorWorker:
                        task.release_resources()