Report the setup failure in the task when available (#781)

This commit is contained in:
Cheick Keita
2021-04-09 05:57:56 -07:00
committed by GitHub
parent 75f0315eb9
commit 80b3533f83
2 changed files with 21 additions and 14 deletions

View File

@ -220,18 +220,19 @@ class Node(BASE_NODE, ORMMixin):
self.stop()
return True
def mark_tasks_stopped_early(self) -> None:
def mark_tasks_stopped_early(self, error: Optional[Error] = None) -> None:
from ..tasks.main import Task
if error is None:
error = Error(
code=ErrorCode.TASK_FAILED,
errors=["node reimaged during task execution"],
)
for entry in NodeTasks.get_by_machine_id(self.machine_id):
task = Task.get_by_task_id(entry.task_id)
if isinstance(task, Task):
task.mark_failed(
Error(
code=ErrorCode.TASK_FAILED,
errors=["node reimaged during task execution"],
)
)
task.mark_failed(error)
def could_shrink_scaleset(self) -> bool:
from .scalesets import ScalesetShrinkQueue