2

I'm trying to update a marathon app via update_app call in Python (I just want to change docker image) but unless I remove version field from the dict returned by get_app I get the error mentioned in the topic. Please explain how app updates should be done and how version & id is related to this. I've read https://mesosphere.github.io/marathon/docs/rest-api.html but it's still not clear to me.

Thank you!

-marek

Here is some of my code:

app = marathon_client.get_app(CONF.application)
# won't work without deleting "version"
# del app["version"]
app["container"]["docker"]["image"] = CONF.docker_image
deployment_id = marathon_client.update_app(CONF.application,
                                           app)

And here is an error:

Traceback (most recent call last):
  File "./update.py", line 122, in <module>
    main()
  File "./update.py", line 104, in main
    deployment_id = marathon_client.update_app(CONF.application, app)
  File "/usr/local/lib/python2.7/dist-packages/dcos/marathon.py", line   343, in update_app
    return self._update(app_id, payload, force)
  File "/usr/local/lib/python2.7/dist-packages/dcos/marathon.py", line 326, in _update
    timeout=self._timeout)
  File "/usr/local/lib/python2.7/dist-packages/dcos/marathon.py", line 121, in _http_req
    raise _to_exception(e.response)
dcos.errors.DCOSException: Error: requirement failed: The 'version'  field may only be combined with the 'id' field.

1 Answers1

1

To update an app, you can provide the new configuration.

Example:

{
"id": "myapp",
"cmd": "sleep 999",
"cpus": 0.3,
"instances": 1,
"mem": 9
}

or you can provide the app id with the version.

Example:

{
"id": "myapp",
"version": "2016-01-21T14:37:29.892Z"
}

This is quite useful if you want to rollback an app.

But you can't provide the new configuration and a version. I agree, the error message is not really clear. There is a ticket on GitHub: https://github.com/mesosphere/marathon/issues/3060

Note: if you get the output from /v2/apps/{app_id} (it looks like: {"app": {"id":...,...},...}) and update the app based on this output, it works even if there is the app id and the app version.

Céline Aussourd
  • 10,214
  • 4
  • 32
  • 36