通过api调用marathon重启app后出现deployment,但是app不会重启,配置如下:
"constraints": [ [ "hostname", "UNIQUE" ], [ "hostname", "LIKE", "HOST-00[12]" ] ]
指定app只能在2个服务器上启动,并且每个服务器只能启动1个instance,
解决方法如下:
"upgradeStrategy": { "maximumOverCapacity": 1, "minimumHealthCapacity": 0.5 }
官方解释如下:
Marathon allows you to perform rolling restarts to deploy new versions of applications. In general, there are two phases to deploying a new version of an application: starting a set of processes with the new version and stopping the set of processes with the old version.
In Marathon, you can perform a rolling restart by defining an upgrade strategy with a
minimumHealthCapacity
at the application level.The minimumHealthCapacity is a percentage which, when applied to the instance count, defines the number of healthy instances that a certain version of the application must have at all times during update. Number of healthy instances is rounded up (ceil).
minimumHealthCapacity
== 0 : All old instances can be killed before the new version is deployed.minimumHealthCapacity
== 1 : All instances of the new version are deployed side by side before the old version is stopped.minimumHealthCapacity
between 0 and 1 : Scale the old version to minimumHealthCapacity and start the new version to minimumHealthCapacity side by side. If this is completed successfully, the new version is scaled to 100% and the old version is stopped. Number of healthy instances is rounded up (ceil). E.g. 3 instances and minimumHealthCapacity 0.7 gives us⌈3 × 0.7⌉ = ⌈2.1⌉ = 3
so all instances will remain.
问题原因:minimumHealthCapacity默认为1,即只有新实例启动之后才会停止老实例,这与hostname:UNIQUE冲突了;
参考:
marathon constraints
https://mesosphere.github.io/marathon/docs/constraints.html
marathon app deployment
http://mesosphere.github.io/marathon/docs/deployments.html