10

I'm trying to run a one-off task with Marathon. I'm able to get the task container running, but after the task command completes, marathon runs another task, and so on. How can I prevent Marathon from running more than one task/command?

Or, if this is not possible with Marathon, how can I achieve the desired behaviour?

Sander Smits
  • 2,051
  • 3
  • 18
  • 16

4 Answers4

9

As a hack you can kill a marathon task at the end, as suggested here: https://github.com/mesosphere/marathon/issues/344#issuecomment-86697361

As rukletsov already mentioned - Marathon is desigend for long-running tasks: https://stackoverflow.com/a/26647789/1047843

If Chronos doesn't fit in your situation you can use Jenkins with Mesos plugin: https://github.com/jenkinsci/mesos-plugin

Or you can try to talk with Mesos directly and write you own framework: http://mesos.apache.org/documentation/latest/app-framework-development-guide/

In my opinion the two easiest options would be Chronos and Jenkins.

Community
  • 1
  • 1
Mik
  • 4,117
  • 1
  • 25
  • 32
  • Plus 1 for Chronos. That is a lot of different answers. – Andrew Scott Evans Aug 03 '16 at 20:39
  • Regarding the suicide hack by using the DELETE API with curl, what can we do if we're using a container and it doesn't have curl installed? Copying/mounting the binary may not work as it may depend on target OS. – ambuj Aug 30 '17 at 11:53
6

Marathon is designed for long running services, which means it will restart the task once it enters a terminal state. Depending on the nature of your task, you may want to take a look at other Mesos frameworks, e.g. Chronos. If you want to start a single task, you can use mesos-execute tool which accompanies Mesos.

rukletsov
  • 1,041
  • 5
  • 7
  • Is it possible to run a service with Chronos now (not scheduled) and once? – Sander Smits Aug 11 '15 at 13:03
  • 1
    I'm not a Chronos expert, but it should understand ISO8601 fine. Try to pass "R1/..." as a value for the "schedule" key in the job description. – rukletsov Aug 11 '15 at 13:12
5

Since the question was answered a new framework called Eremetic has been developed for marathon that allows you to run one off tasks.

https://github.com/klarna/eremetic

McGin
  • 1,361
  • 2
  • 13
  • 31
0

@Sander Smits: How @rukletsov wrote you can use the repeating intervals ISO8601 to execute services only one time. After the execution the job will be automatically disabled by chronos. Use"R0/.." (0 repetition) for schedule setting.

MarX
  • 1
  • 2