Class: Moonshot::Tools::ASGRollout
- Inherits:
-
Object
- Object
- Moonshot::Tools::ASGRollout
- Defined in:
- lib/moonshot/tools/asg_rollout.rb,
lib/moonshot/tools/asg_rollout/asg.rb,
lib/moonshot/tools/asg_rollout/asg_instance.rb,
lib/moonshot/tools/asg_rollout/instance_health.rb,
lib/moonshot/tools/asg_rollout/hook_exec_environment.rb
Defined Under Namespace
Classes: ASG, ASGInstance, HookExecEnvironment, InstanceHealth
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
-
#initialize(controller:, logical_id:) {|@config| ... } ⇒ ASGRollout
constructor
A new instance of ASGRollout.
- #run! ⇒ Object
Constructor Details
#initialize(controller:, logical_id:) {|@config| ... } ⇒ ASGRollout
Returns a new instance of ASGRollout.
10 11 12 13 14 15 |
# File 'lib/moonshot/tools/asg_rollout.rb', line 10 def initialize(controller:, logical_id:) @config = ASGRolloutConfig.new @controller = controller @logical_id = logical_id yield @config if block_given? end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
8 9 10 |
# File 'lib/moonshot/tools/asg_rollout.rb', line 8 def config @config end |
Instance Method Details
#run! ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/moonshot/tools/asg_rollout.rb', line 17 def run! increase_max_and_desired new_instance = wait_for_new_instance wait_for_in_service(new_instance) targets = asg.non_conforming_instances last_instance = targets.last targets.each do |instance| run_pre_detach(instance) if @config.pre_detach detach(instance, decrement: instance == last_instance) wait_for_out_of_service(instance) unless instance == last_instance new_instance = wait_for_new_instance wait_for_in_service(new_instance) end wait_for_terminate_when_hook(instance) if @config.terminate_when terminate(instance) end ensure log.start_threaded 'Restoring MaxSize/DesiredCapacity values to normal...' do |s| asg.set_max_and_desired(@max, @desired) s.success 'Restored MaxSize/DesiredCapacity values to normal!' end end |