0

I'm trying to invoke the marathon API to suspend a job. I don't see in the API docs how to do it, but I thought that I could do it by setting instance = 0. But all that's done is cause my job to enter the "Deploying..." state (apparently forever). On the other hand, when I suspend a job using the marathon web portal, it gets suspended right away.

Does anyone know how to do this?

$.fn.suspendjob = function(id) {
$.ajax({
  type: 'PUT',
  url: 'https://mesos-head.achillesv.net/marathon/v2/apps' + id,
  headers: {
    "Authorization": "Basic " + btoa(user + ":" + pass)
  },
  data: JSON.stringify({ instances: 0}),
  contentType: "application/json; charset=utf-8",
  success: function(result) {
    appslist.length = 0;
    $('#tabs').tabs("option", "active", 1);
    $('#tabs').tabs("option", "active", 0);
  }
});

};

Robert Stober
  • 53
  • 1
  • 7

2 Answers2

1

I think your solution is good (set instance = 0). I tried this solution and it worked. Please try again!

xuanhai266
  • 423
  • 3
  • 13
1

A small python script to achieve this (It assumes marathon is running on localhost on port 8080):

    import requests

    marathon = "http://localhost:8080/v2/apps/<app-name>"
    payload = {'instances': 0}
    r = requests.put(marathon+"?force=true", json=payload)     
    #'?force=true' will be useful if an app is in deploying state
    print r.status_code, r.reason