class Marathon::Group
This class represents a Marathon
Group
. See mesosphere.github.io/marathon/docs/rest-api.html#groups for full list of API's methods.
Constants
- ACCESSORS
- DEFAULTS
Attributes
Public Class Methods
Create a new group object. hash
: Hash including all attributes.
See https://mesosphere.github.io/marathon/docs/rest-api.html#post-/v2/groups for full details.
marathon_instance
: MarathonInstance holding a connection to marathon
Marathon::Base::new
# File lib/marathon/group.rb, line 17 def initialize(hash, marathon_instance = Marathon.singleton) super(Marathon::Util.merge_keywordized_hash(DEFAULTS, hash), ACCESSORS) @marathon_instance = marathon_instance raise ArgumentError, 'Group must have an id' unless id refresh_attributes end
Private Class Methods
Change parameters of a deployed application group. Changes to application parameters will result in a restart of this application. A new application added to the group is started. An existing application removed from the group gets stopped. If there are no changes to the application definition, no restart is triggered. During restart marathon keeps track, that the configured amount of minimal running instances are always available. A deployment can run forever. This is the case, when the new application has a problem and does not become healthy. In this case, human interaction is needed with 2 possible choices: Rollback to an existing older version (send an existing version in the body) Update with a newer version of the group which does not have the problems of the old one. If there is an upgrade process already in progress, a new update will be rejected unless the force flag is set. With the force flag given, a running upgrade is terminated and a new one is started. Since the deployment of the group can take a considerable amount of time, this endpoint returns immediatly with a version. The failure or success of the action is signalled via event. There is a group_change_success and group_change_failed event with the given version. id
: Group's id. hash
: Hash of attributes to change. force
: If the group is affected by a running deployment, then the update operation will fail.
The current deployment can be overridden by setting the `force` query parameter.
dry_run
: Get a preview of the deployment steps Marathon
would run for a given group update.
# File lib/marathon/group.rb, line 161 def change(id, hash, force = false, dry_run = false) Marathon.singleton.groups.change(id, hash, force, dry_run) end
Delete the application group with id. id
: Group's id. force
: If the group is affected by a running deployment, then the update operation will fail.
The current deployment can be overridden by setting the `force` query parameter.
# File lib/marathon/group.rb, line 121 def delete(id, force = false) Marathon.singleton.groups.delete(id, force) end
List the group with the specified ID. id
: Group's id.
# File lib/marathon/group.rb, line 108 def get(id) Marathon.singleton.groups.get(id) end
List all groups.
# File lib/marathon/group.rb, line 113 def list Marathon.singleton.groups.list end
Create and start a new application group. Application groups can contain other application groups. An application group can either hold other groups or applications, but can not be mixed in one. Since the deployment of the group can take a considerable amount of time, this endpoint returns immediatly with a version. The failure or success of the action is signalled via event. There is a group_change_success and group_change_failed event with the given version. hash
: Hash including all attributes
see https://mesosphere.github.io/marathon/docs/rest-api.html#post-/v2/groups for full details
# File lib/marathon/group.rb, line 134 def start(hash) Marathon.singleton.groups.start(hash) end
Public Instance Methods
Change parameters of a deployed application group. Changes to application parameters will result in a restart of this application. A new application added to the group is started. An existing application removed from the group gets stopped. If there are no changes to the application definition, no restart is triggered. During restart marathon keeps track, that the configured amount of minimal running instances are always available. A deployment can run forever. This is the case, when the new application has a problem and does not become healthy. In this case, human interaction is needed with 2 possible choices: Rollback to an existing older version (send an existing version in the body) Update with a newer version of the group which does not have the problems of the old one. If there is an upgrade process already in progress, a new update will be rejected unless the force flag is set. With the force flag given, a running upgrade is terminated and a new one is started. Since the deployment of the group can take a considerable amount of time, this endpoint returns immediatly with a version. The failure or success of the action is signalled via event. There is a group_change_success and group_change_failed event with the given version. hash
: Hash of attributes to change. force
: If the group is affected by a running deployment, then the update operation will fail.
The current deployment can be overridden by setting the `force` query parameter.
dry_run
: Get a preview of the deployment steps Marathon
would run for a given group update.
# File lib/marathon/group.rb, line 59 def change!(hash, force = false, dry_run = false) Marathon::Util.keywordize_hash!(hash) if hash[:version] and hash.size > 1 # remove :version if it's not the only key new_hash = Marathon::Util.remove_keys(hash, [:version]) else new_hash = hash end @marathon_instance.groups.change(id, new_hash, force, dry_run) end
Reload attributes from marathon API.
# File lib/marathon/group.rb, line 25 def refresh new_app = @marathon_instance.groups.get(id) @info = new_app.info refresh_attributes end
Create a new version with parameters of an old version. Currently running tasks are restarted, while maintaining the minimumHealthCapacity. version
: Version name of the old version. force
: If the group is affected by a running deployment, then the update operation will fail.
The current deployment can be overridden by setting the `force` query parameter.
# File lib/marathon/group.rb, line 75 def roll_back!(version, force = false) change!({'version' => version}, force) end
Create and start a the application group. Application groups can contain other application groups. An application group can either hold other groups or applications, but can not be mixed in one. Since the deployment of the group can take a considerable amount of time, this endpoint returns immediatly with a version. The failure or success of the action is signalled via event. There is a group_change_success and group_change_failed event with the given version.
# File lib/marathon/group.rb, line 36 def start! @marathon_instance.groups.start(info) end
Returns a string for listing the group.
# File lib/marathon/group.rb, line 84 def to_pretty_s %Q[ Group ID: #{id} #{pretty_array(apps)} #{pretty_array(groups)} Version: #{version} ].gsub(/\n\n+/, "\n").strip end
# File lib/marathon/group.rb, line 79 def to_s "Marathon::Group { :id => #{id} }" end
Private Instance Methods
# File lib/marathon/group.rb, line 95 def pretty_array(array) array.map { |e| e.to_pretty_s.split("\n").map { |e| " #{e}" } }.join("\n") end
Rebuild attribute classes
# File lib/marathon/group.rb, line 100 def refresh_attributes @apps = (info[:apps] || []).map { |e| Marathon::App.new(e, @marathon_instance) } @groups = (info[:groups] || []).map { |e| Marathon::Group.new(e, @marathon_instance) } end