mark tasks that are stopped that never started with an error (#935)

This commit is contained in:
bmc-msft
2021-05-26 18:42:21 -04:00
committed by GitHub
parent 87eb8ac80a
commit d557fc16c6
2 changed files with 6 additions and 1 deletions

View File

@ -195,6 +195,11 @@ class Task(BASE_TASK, ORMMixin):
)
return
if self.state not in TaskState.has_started():
self.mark_failed(
Error(code=ErrorCode.TASK_FAILED, errors=["task never started"])
)
self.set_state(TaskState.stopping)
def mark_failed(

View File

@ -19,7 +19,7 @@ def main(mytimer: func.TimerRequest, dashboard: func.Out[str]) -> None: # noqa:
expired_tasks = Task.search_expired()
for task in expired_tasks:
logging.info("stopping expired task: %s", task.job_id)
task.stopping()
task.mark_stopping()
expired_jobs = Job.search_expired()
for job in expired_jobs: