Class: Vector::Function::FlexibleDownScaling
- Inherits:
-
Object
- Object
- Vector::Function::FlexibleDownScaling
- Includes:
- HLogger
- Defined in:
- lib/vector/functions/flexible_down_scaling.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ FlexibleDownScaling
constructor
A new instance of FlexibleDownScaling.
- #run_for(group, ps_check_procs) ⇒ Object
Methods included from HLogger
Constructor Details
#initialize(options) ⇒ FlexibleDownScaling
Returns a new instance of FlexibleDownScaling.
8 9 10 11 12 13 |
# File 'lib/vector/functions/flexible_down_scaling.rb', line 8 def initialize() @cloudwatch = [:cloudwatch] @up_down_cooldown = [:up_down_cooldown] @down_down_cooldown = [:down_down_cooldown] @max_sunk_cost = [:max_sunk_cost] end |
Instance Method Details
#run_for(group, ps_check_procs) ⇒ Object
15 16 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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/vector/functions/flexible_down_scaling.rb', line 15 def run_for(group, ps_check_procs) result = { :triggered => false } hlog_ctx("fds") do hlog_ctx("group:#{group.name}") do # don't check if no config was specified if @up_down_cooldown.nil? && @down_down_cooldown.nil? hlog("No cooldown periods specified, exiting") return result end # don't bother checking for a scaledown if desired capacity is # already at the minimum size... if group.desired_capacity == group.min_size hlog("Group is already at minimum size, exiting") return result end scaledown_policies = group.scaling_policies.select do |policy| policy.scaling_adjustment < 0 end scaledown_policies.each do |policy| hlog_ctx("policy:#{policy.name}") do # TODO: support adjustment types other than ChangeInCapacity here if policy.adjustment_type == "ChangeInCapacity" && ps_check_procs.any? {|ps_check_proc| ps_check_proc.call(group.desired_capacity + policy.scaling_adjustment) } hlog("Predictive scaleup would trigger a scaleup if group were shrunk") next end alarms = policy.alarms.keys.map do |alarm_name| @cloudwatch.alarms[alarm_name] end # only consider disabled alarms (enabled alarms will trigger # the policy automatically) disabled_alarms = alarms.select do |alarm| !alarm.enabled? end unless disabled_alarms.all? {|alarm| alarm.state_value == "ALARM" } hlog("Not all alarms are in ALARM state") next end unless outside_cooldown_period(group) hlog("Group is not outside the specified cooldown periods") next end unless has_eligible_scaledown_instance(group) hlog("Group does not have an instance eligible for scaledown due to max_sunk_cost") next end hlog("Executing policy") policy.execute(:honor_cooldown => true) result[:triggered] = true # no need to evaluate other scaledown policies return result end end end end result end |