Search code examples
mesosmarathon

Configure Marathon to not restart tasks that enter TASK_FINISHED


I launch tasks via Marathon. However they finish, Marathon restarts them. I would like them to only restart if they finish in failure. Is there a way such that if the task enters the state of TaskStatus.TASK_FINISHED that Marathon will not restart it, e.g., by suspending the job, i.e., by setting the number of tasks to zero?

Currently when my task completes successfully I PUT a message to the Marathon REST API scaling the job down to 0 instances. This is fine except that in response Marathon kills the task setting its status to TASK_KILLED and I would like it to be TASK_FINISHED to indicate its success.


Solution

  • If you have one-of tasks as you describe, I think the better solution would be to use a scheduler like

    Marathon is normally used to keep tasks running, and rescheduling them if they reach a final task state.

    See the Marathon docs, and also this explanation of different task types.