| 1 | package App::FargateStack::AutoscalingConfig; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use App::FargateStack::Constants; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use App::FargateStack::Builder::Utils qw(dmp choose); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use English qw(no_match_vars); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use List::Util qw(none uniq); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | __PACKAGE__->follow_best_practice; | |||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | __PACKAGE__->mk_accessors( | |||||||||||||||||||||||||||||||||||||||||
| 15 | qw( | ||||||||||||||||||||||||||||||||||||||||||
| 16 | config | ||||||||||||||||||||||||||||||||||||||||||
| 17 | cpu | ||||||||||||||||||||||||||||||||||||||||||
| 18 | max_capacity | ||||||||||||||||||||||||||||||||||||||||||
| 19 | metric | ||||||||||||||||||||||||||||||||||||||||||
| 20 | min_capacity | ||||||||||||||||||||||||||||||||||||||||||
| 21 | policy_arn | ||||||||||||||||||||||||||||||||||||||||||
| 22 | policy_name | ||||||||||||||||||||||||||||||||||||||||||
| 23 | requests | ||||||||||||||||||||||||||||||||||||||||||
| 24 | scale_in_cooldown | ||||||||||||||||||||||||||||||||||||||||||
| 25 | scale_out_cooldown | ||||||||||||||||||||||||||||||||||||||||||
| 26 | scheduled_actions | ||||||||||||||||||||||||||||||||||||||||||
| 27 | task_name | ||||||||||||||||||||||||||||||||||||||||||
| 28 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | use parent qw(Class::Accessor::Fast); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | my ( $class, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | my $options = ref $args[0] ? $args[0] : {@args}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | die 'usage: App::FargateStack::AutoscalingConfig->new(config => autoscaling-config)' | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if !$options->{config}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | my $self = $class->SUPER::new($options); | |||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | foreach (qw(cpu requests scale_in_cooldown scale_out_cooldown policy_name)) { | |||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | next if !defined $self->get($_); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $self->update( $_ => $self->get($_) ); | |||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $self->parse_metric(); | |||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | if ( $self->get_cpu || $self->get_requests ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->get_cpu or $self->get_requests
MC/DC0%0/2
$self->get_cpu or $self->get_requests
$self->get_cpu
$self->get_requests
Truth table0%0/3
A or B
A= $self->get_cpuB= $self->get_requests
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 0 | $self->parse_cooldown(); | |||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | $self->parse_scaling_capacity(); | |||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | $self->parse_scheduled_actions(); | |||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | $self->sanity_check(); | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | sub sanity_check { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sanity_check: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | die 'autoscaling: cpu & requests are mutually exclusive' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->get_cpu and $self->get_requests
MC/DC0%0/2
$self->get_cpu and $self->get_requests
$self->get_cpu
$self->get_requests
Truth table0%0/3
A and B
A= $self->get_cpuB= $self->get_requests
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | if $self->get_cpu && $self->get_requests; | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub update { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
update: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my ( $self, $key, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $self->get_config->{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | return $self->set( $key, $value ); | |||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | sub has_scheduled_action { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_scheduled_action: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | return exists $self->get_config->{scheduled}; | |||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | sub parse_scheduled_actions { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_scheduled_actions: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | return | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | if !$self->has_scheduled_action; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my $scheduled = $self->get_config->{scheduled}; | |||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my %scheduled_actions; | |||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | foreach my $scheduled_action_name ( keys %{$scheduled} ) { | |||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $scheduled_actions{$scheduled_action_name} = $self->_parse_scheduled_action( $scheduled->{$scheduled_action_name} ); | |||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $self->set_scheduled_actions( \%scheduled_actions ); | |||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | sub parse_cooldown { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_cooldown: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | return | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | if !$self->get_cpu && !$self->get_requests; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->get_cpu or $self->get_requests
MC/DC0%0/2
$self->get_cpu or $self->get_requests
$self->get_cpu
$self->get_requests
Truth table0%0/3
A or B
A= $self->get_cpuB= $self->get_requests
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $config = $self->get_config; | |||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | my $scale_out_cooldown = $self->get_scale_out_cooldown // $config->{scale_out_cooldown}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->get_scale_out_cooldown // $config->{"scale_out_cooldown"}
MC/DC0%0/2
$self->get_scale_out_cooldown // $config->{"scale_out_cooldown"}
$self->get_scale_out_cooldown
$config->{"scale_out_cooldown"}
Truth table0%0/3
A // B
A= $self->get_scale_out_cooldownB= $config->{"scale_out_cooldown"}
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | my $scale_in_cooldown = $self->get_scale_in_cooldown // $config->{scale_in_cooldown}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->get_scale_in_cooldown // $config->{"scale_in_cooldown"}
MC/DC0%0/2
$self->get_scale_in_cooldown // $config->{"scale_in_cooldown"}
$self->get_scale_in_cooldown
$config->{"scale_in_cooldown"}
Truth table0%0/3
A // B
A= $self->get_scale_in_cooldownB= $config->{"scale_in_cooldown"}
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | $scale_out_cooldown ||= $DEFAULT_AUTOSCALING_SCALE_OUT_COOLDOWN; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$scale_out_cooldown ||= $App::FargateStack::AutoscalingConfig::DEFAULT_AUTOSCALING_SCALE_OUT_COOLDOWN
MC/DC0%0/2
$scale_out_cooldown ||= $App::FargateStack::AutoscalingConfig::DEFAULT_AUTOSCALING_SCALE_OUT_COOLDOWN
$scale_out_cooldown
$App::FargateStack::AutoscalingConfig::DEFAULT_AUTOSCALING_SCALE_OUT_COOLDOWN
Truth table0%0/3
A ||= B
A= $scale_out_cooldownB= $App::FargateStack::AutoscalingConfig::DEFAULT_AUTOSCALING_SCALE_OUT_COOLDOWN
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | $scale_in_cooldown ||= $DEFAULT_AUTOSCALING_SCALE_IN_COOLDOWN; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$scale_in_cooldown ||= $App::FargateStack::AutoscalingConfig::DEFAULT_AUTOSCALING_SCALE_IN_COOLDOWN
MC/DC0%0/2
$scale_in_cooldown ||= $App::FargateStack::AutoscalingConfig::DEFAULT_AUTOSCALING_SCALE_IN_COOLDOWN
$scale_in_cooldown
$App::FargateStack::AutoscalingConfig::DEFAULT_AUTOSCALING_SCALE_IN_COOLDOWN
Truth table0%0/3
A ||= B
A= $scale_in_cooldownB= $App::FargateStack::AutoscalingConfig::DEFAULT_AUTOSCALING_SCALE_IN_COOLDOWN
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $self->update( scale_out_cooldown => int $scale_out_cooldown ); | |||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | $self->update( scale_in_cooldown => int $scale_in_cooldown ); | |||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | sub parse_scaling_capacity { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_scaling_capacity: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | return | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | if !$self->get_cpu && !$self->get_requests; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->get_cpu or $self->get_requests
MC/DC0%0/2
$self->get_cpu or $self->get_requests
$self->get_cpu
$self->get_requests
Truth table0%0/3
A or B
A= $self->get_cpuB= $self->get_requests
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | my $config = $self->get_config; | |||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | my $min_capacity = $self->get_min_capacity // $config->{min_capacity}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->get_min_capacity // $config->{"min_capacity"}
MC/DC0%0/2
$self->get_min_capacity // $config->{"min_capacity"}
$self->get_min_capacity
$config->{"min_capacity"}
Truth table0%0/3
A // B
A= $self->get_min_capacityB= $config->{"min_capacity"}
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | my $max_capacity = $self->get_max_capacity // $config->{max_capacity}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$self->get_max_capacity // $config->{"max_capacity"}
MC/DC0%0/2
$self->get_max_capacity // $config->{"max_capacity"}
$self->get_max_capacity
$config->{"max_capacity"}
Truth table0%0/3
A // B
A= $self->get_max_capacityB= $config->{"max_capacity"}
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | $min_capacity ||= $DEFAULT_AUTOSCALING_MIN_CAPACITY; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$min_capacity ||= $App::FargateStack::AutoscalingConfig::DEFAULT_AUTOSCALING_MIN_CAPACITY
MC/DC0%0/2
$min_capacity ||= $App::FargateStack::AutoscalingConfig::DEFAULT_AUTOSCALING_MIN_CAPACITY
$min_capacity
$App::FargateStack::AutoscalingConfig::DEFAULT_AUTOSCALING_MIN_CAPACITY
Truth table0%0/3
A ||= B
A= $min_capacityB= $App::FargateStack::AutoscalingConfig::DEFAULT_AUTOSCALING_MIN_CAPACITY
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | $max_capacity ||= $DEFAULT_AUTOSCALING_MAX_CAPACITY; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$max_capacity ||= $App::FargateStack::AutoscalingConfig::DEFAULT_AUTOSCALING_MAX_CAPACITY
MC/DC0%0/2
$max_capacity ||= $App::FargateStack::AutoscalingConfig::DEFAULT_AUTOSCALING_MAX_CAPACITY
$max_capacity
$App::FargateStack::AutoscalingConfig::DEFAULT_AUTOSCALING_MAX_CAPACITY
Truth table0%0/3
A ||= B
A= $max_capacityB= $App::FargateStack::AutoscalingConfig::DEFAULT_AUTOSCALING_MAX_CAPACITY
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | die sprintf 'autoscaling: min_capacity [%s] must be less than max_capacity [%s]', $min_capacity, $max_capacity | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | if $min_capacity > $max_capacity; | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | $self->update( min_capacity => int $min_capacity ); | |||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | $self->update( max_capacity => int $max_capacity ); | |||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | sub get_metric_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_metric_value: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | return $self->get( $self->get_metric ); | |||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | sub parse_metric { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_metric: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | my $config = $self->get_config; | |||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my $metric = $self->get_metric; | |||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | if ( $metric && $metric =~ /^(cpu|requests)[: \-,](\d+)$/xsm ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition0%0/3
$metric and $metric =~ /^(cpu|requests)[: \-,](\d+)$/msx
MC/DC0%0/2
$metric and $metric =~ /^(cpu|requests)[: \-,](\d+)$/msx
$metric
$metric =~ /^(cpu|requests)[: \-,](\d+)$/msx
Truth table0%0/3
A and B
A= $metricB= $metric =~ /^(cpu|requests)[: \-,](\d+)$/msx
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $metric = $1; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | $config->{$1} = $2; | |||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | elsif ( defined $self->get_cpu ) { | ||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | $config->{cpu} = $self->get_cpu; | |||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | elsif ( defined $self->get_requests ) { | ||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | $config->{requests} = $self->get_requests; | |||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | my @metric = choose { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | return ( 'cpu', int $config->{cpu} ) | ||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | if defined $config->{cpu}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | return ( 'requests', int $config->{requests} ) | ||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | if defined $config->{requests}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | # scheduled only? | ||||||||||||||||||||||||||||||||||||||||||
| 199 | return ( $config->{scheduled}, 0 ) | ||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | if defined $config->{scheduled}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | die 'autoscaling: autoscaling type must be one of "cpu", "requests" or "scheduled"' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | if !@metric; | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | return # scheduled | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | if !$metric[1]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $self->set_metric( $metric[0] ); | |||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | $self->update( $metric[0] => $metric[1] ); | |||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | =pod | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | =head2 parse_scheduled_action | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | my $action_hash = $self->parse_scheduled_action( $scheduled_action_hash ); | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | This is a private helper subroutine that acts as the primary parser and validator | ||||||||||||||||||||||||||||||||||||||||||
| 225 | for the user-defined schedule configuration. It takes a single, user-configured | ||||||||||||||||||||||||||||||||||||||||||
| 226 | schedule hash (e.g., the business_hours block) and translates it into a | ||||||||||||||||||||||||||||||||||||||||||
| 227 | complex data structure containing the two distinct, API-ready "ScaleOut" and | ||||||||||||||||||||||||||||||||||||||||||
| 228 | "ScaleIn" actions required by AWS. | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | The subroutine's main responsibilities are: | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | Parsing: It parses the user-friendly start_time, end_time, days, | ||||||||||||||||||||||||||||||||||||||||||
| 237 | min_capacity, and max_capacity values. It supports flexible delimiters | ||||||||||||||||||||||||||||||||||||||||||
| 238 | for capacity pairs and both textual and numeric day representations. | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | Validation: It performs a series of critical, upfront validation checks. | ||||||||||||||||||||||||||||||||||||||||||
| 243 | If any part of the configuration is missing, malformed, or logically | ||||||||||||||||||||||||||||||||||||||||||
| 244 | inconsistent (e.g., a scale-in capacity is larger than a scale-out capacity), | ||||||||||||||||||||||||||||||||||||||||||
| 245 | the subroutine will abort the entire process with a clear, descriptive error | ||||||||||||||||||||||||||||||||||||||||||
| 246 | message. | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | Transformation: It transforms the validated user input into two separate, | ||||||||||||||||||||||||||||||||||||||||||
| 251 | syntactically correct AWS cron expressions (cron(...)) for the scale-out and | ||||||||||||||||||||||||||||||||||||||||||
| 252 | scale-in events. | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | =item * | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | Structuring: It builds and returns a nested hash that precisely mirrors | ||||||||||||||||||||||||||||||||||||||||||
| 257 | the data structure needed for the put-scheduled-action API calls, separating | ||||||||||||||||||||||||||||||||||||||||||
| 258 | the ScaleOut and ScaleIn actions, each with their own Schedule string and | ||||||||||||||||||||||||||||||||||||||||||
| 259 | Action hash containing the corresponding capacity limits. | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | =head3 Arguments | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | =item * C<$scheduled_action> | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | A hash reference corresponding to a single named schedule from the user's YAML | ||||||||||||||||||||||||||||||||||||||||||
| 270 | configuration. It is expected to contain the following keys: | ||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | =over 8 | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | =item * C<start_time> (e.g., "09:00") | ||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | =item * C<end_time> (e.g., "17:00") | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | =item * C<days> (e.g., "MON-FRI", "2-6") | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | =item * C<min_capacity> (e.g., "2/1", "2-1") | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | =item * C<max_capacity> (e.g., "4/1", "4-1") | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | =head3 Returns | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | A hash reference containing two keys, C<ScaleOut> and C<ScaleIn>. Each of these | ||||||||||||||||||||||||||||||||||||||||||
| 291 | keys contains another hash with the fully-formed C<Action> and C<Schedule> | ||||||||||||||||||||||||||||||||||||||||||
| 292 | sub-hashes required for the final API calls. | ||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | sub _parse_scheduled_action { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse_scheduled_action: not called CC=23 SCAR=63.1
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my ( $self, $scheduled_action ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | my ( $start_time, $end_time, $days ) = @{$scheduled_action}{qw(start_time end_time days)}; | |||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | die 'autoscaling: you must include start_time, end_time, and days for a scheduled action' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$start_time and $end_time and $days
$start_time and $end_time
MC/DC0%0/3
$start_time and $end_time and $days
$start_time
$end_time
$days
Truth table0%0/4
A and B and C
A= $start_timeB= $end_timeC= $days
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | if !$start_time || !$end_time || !$days; | ||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | my (@start_times) = split /:/xsm, $start_time; | |||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | my (@end_times) = split /:/xsm, $end_time; | |||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | die sprintf 'autoscaling: invalid start time: [%s]', $start_time | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$start_times[0] < 0 or $start_times[0] > 59
MC/DC0%0/2
$start_times[0] < 0 or $start_times[0] > 59
$start_times[0] < 0
$start_times[0] > 59
Truth table0%0/3
A or B
A= $start_times[0] < 0B= $start_times[0] > 59
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | if $start_times[0] < 0 || $start_times[0] > 59; | ||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | die sprintf 'autoscaling: invalid start time: [%s]', $start_time | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$start_times[1] < 0 or $start_times[1] > 23
MC/DC0%0/2
$start_times[1] < 0 or $start_times[1] > 23
$start_times[1] < 0
$start_times[1] > 23
Truth table0%0/3
A or B
A= $start_times[1] < 0B= $start_times[1] > 23
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | if $start_times[1] < 0 || $start_times[1] > 23; | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | die sprintf 'autoscaling: invalid end time: [%s]', $end_time | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$start_times[0] < 0 or $start_times[0] > 59
MC/DC0%0/2
$start_times[0] < 0 or $start_times[0] > 59
$start_times[0] < 0
$start_times[0] > 59
Truth table0%0/3
A or B
A= $start_times[0] < 0B= $start_times[0] > 59
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | if $start_times[0] < 0 || $start_times[0] > 59; | ||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | die sprintf 'autoscaling: invalid end time: [%s]', $end_time | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$start_times[1] < 0 or $start_times[1] > 23
MC/DC0%0/2
$start_times[1] < 0 or $start_times[1] > 23
$start_times[1] < 0
$start_times[1] > 23
Truth table0%0/3
A or B
A= $start_times[1] < 0B= $start_times[1] > 23
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | if $start_times[1] < 0 || $start_times[1] > 23; | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | my @days_parsed = split /[\/\-: ,]/xsmi, $days; | |||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | if ( @days_parsed == 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | push @days_parsed, @days_parsed; | |||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | my %day_names = qw(SUN 1 MON 2 TUE 3 WED 4 THU 5 FRI 6 SAT 7); | |||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | my %day_nums = reverse %day_names; | |||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | foreach my $day (@days_parsed) { | |||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | if ( $day =~ /^\d$/xsmi ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | $day =~ s/^[1-7]$/$day_nums{$day}/xsm; | |||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||
| 336 | die sprintf 'autoscaling: invalid day: [%s]', $day | ||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | if none { $day eq $_ } keys %day_names; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | die sprintf 'autoscaling: invalid day range [%s] - [%s]', @days_parsed | ||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | if $day_names{ $days_parsed[0] } > $day_names{ $days_parsed[1] }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my ( $min_capacity, $max_capacity ) = @{$scheduled_action}{qw(min_capacity max_capacity)}; | |||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | die 'autoscaling: both min_capacity and max_capacity must be provided' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$max_capacity and $min_capacity
MC/DC0%0/2
$max_capacity and $min_capacity
$max_capacity
$min_capacity
Truth table0%0/3
A and B
A= $max_capacityB= $min_capacity
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | if !$max_capacity || !$min_capacity; | ||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | my @min_capacities = split /[: ,\/\-]/xsm, $min_capacity; | |||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | my @max_capacities = split /[: ,\/\-]/xsm, $max_capacity; | |||||||||||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | die 'autoscaling: min_capacity must be a tuple (ex: 2/1)' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 353 | if @min_capacities != 2; | ||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | die 'autoscaling: scale in min capacity should be <= scale out min capacity' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 356 | if $min_capacities[0] < $min_capacities[1]; | ||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | die 'autoscaling: max_capacity must be a tuple (ex: 2/1)' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | if @max_capacities != 2; | ||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | die 'autoscaling: scale in max capacity should be <= scale out max capacity' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | if $max_capacities[0] < $max_capacities[1]; | ||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | $days_parsed[0] = $day_names{ $days_parsed[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | $days_parsed[1] = $day_names{ $days_parsed[1] }; | |||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my $action = { | |||||||||||||||||||||||||||||||||||||||||
| 368 | ScaleOut => { | ||||||||||||||||||||||||||||||||||||||||||
| 369 | Action => { | ||||||||||||||||||||||||||||||||||||||||||
| 370 | MinCapacity => int $min_capacities[0], | ||||||||||||||||||||||||||||||||||||||||||
| 371 | MaxCapacity => int $max_capacities[0], | ||||||||||||||||||||||||||||||||||||||||||
| 372 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 373 | Schedule => sprintf 'cron(%02d %02d ? * %s *)', | ||||||||||||||||||||||||||||||||||||||||||
| 374 | @start_times, | ||||||||||||||||||||||||||||||||||||||||||
| 375 | join q{-}, | ||||||||||||||||||||||||||||||||||||||||||
| 376 | uniq @days_parsed, | ||||||||||||||||||||||||||||||||||||||||||
| 377 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 378 | ScaleIn => { | ||||||||||||||||||||||||||||||||||||||||||
| 379 | Action => { | ||||||||||||||||||||||||||||||||||||||||||
| 380 | MinCapacity => int $min_capacities[1], | ||||||||||||||||||||||||||||||||||||||||||
| 381 | MaxCapacity => int $max_capacities[1], | ||||||||||||||||||||||||||||||||||||||||||
| 382 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 383 | Schedule => sprintf 'cron(%02d %02d ? * %s *)', | ||||||||||||||||||||||||||||||||||||||||||
| 384 | @end_times, | ||||||||||||||||||||||||||||||||||||||||||
| 385 | join q{-}, | ||||||||||||||||||||||||||||||||||||||||||
| 386 | uniq @days_parsed, | ||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||
| 388 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | return $action; | |||||||||||||||||||||||||||||||||||||||||
| 391 | } | ||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||