def statusUpdate(self, driver, update): try: t = HippoTask(mesos_id=update.task_id.value,redis_client=self.redis) t.definition['mesos_state'] = update.state t.save() if update.state in ['TASK_FINISHED','TASK_FAILED','TASK_LOST','TASK_ERROR','TASK_DROPPED', 'TASK_KILLED','TASK_UNREACHABLE','TASK_GONE','TASK_GONE_BY_OPERATOR']: t.finish() if update.state != 'TASK_FINISHED': t.retry() except redis.exceptions.ConnectionError: logging.warning('Redis Connection Error in Scheduler statusUpdate') logging.info('Status update TID %s %s', update.task_id.value, update.state)
def test_retry(self): x = HippoTask(definition={'id':'foo'},redis_client=self.redis_client) x.queue() x.work() x.definition['task_retries'] = 1 x.definition['mesos_state'] = 'TASK_FAILED' x.finish() x.retry() self.assertEqual(len(HippoTask.all_tasks(self.redis_client)),2) waiting_tasks = HippoTask.waiting_tasks(self.redis_client) self.assertEqual(len(waiting_tasks),1) w = waiting_tasks[0] self.assertEqual(w.definition['task_retries'],0) w.finish() w.definition['mesos_state'] = 'TASK_LOST' w.retry() self.assertEqual(len(HippoTask.waiting_tasks(self.redis_client)),2)