| 1 | package App::FargateStack::Autoscaling; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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::AutoscalingConfig; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use App::FargateStack::Constants; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use App::FargateStack::Builder::Utils qw(dmp choose confirm); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use CLI::Simple::Constants qw(:booleans); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use List::Util qw(none); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use English qw(no_match_vars); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Role::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | sub cmd_delete_scheduled_action { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_delete_scheduled_action: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | my @all_scheduled_actions = $self->get_scheduled_action_names; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | croak "ERROR: there are no scheduled actions in your configuration\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | if !@all_scheduled_actions; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | my ($scheduled_action) = $self->get_args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | croak "ERROR: usage: delete-scheduled-action scheduled-action-name\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $scheduled_action and @all_scheduled_actions != 1
MC/DC0%0/2
not $scheduled_action and @all_scheduled_actions != 1
not $scheduled_action
@all_scheduled_actions != 1
Truth table0%0/3
not(A) and B
A= not $scheduled_actionB= @all_scheduled_actions != 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | if !$scheduled_action && @all_scheduled_actions != 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | $scheduled_action = $all_scheduled_actions[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | croak sprintf "ERROR: no scheduled action: %s in configuration\n", $scheduled_action | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | if none { $scheduled_action eq $_ } $self->get_scheduled_action_names; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | my $config = $self->get_config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | my $app_autoscaling = $self->fetch_application_autoscaling; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | foreach my $task ( keys %{ $config->{tasks} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | next if !exists $config->{tasks}->{$task}->{autoscaling}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | next if !exists $config->{tasks}->{$task}->{autoscaling}->{scheduled}->{$scheduled_action}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | my $resource_id = $self->_resource_id($task); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | ▶ | if ( !$self->get_force ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | if ( !confirm( 'Are you sure you want to deleted scheduled action "%s"', $scheduled_action ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | print {*STDOUT} "Aborting...\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | return $SUCCESS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | foreach (qw(in out)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my $scheduled_action_name = $self->create_default( 'scheduled-action-name', $scheduled_action . qw{-} . $_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | $app_autoscaling->delete_scheduled_action( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | service_namespace => 'ecs', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | scheduled_action_name => $scheduled_action_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | resource_id => $resource_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | scalable_dimension => 'ecs:service:DesiredCount', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | $app_autoscaling->check_result( message => 'ERROR: could not delete scheduled action: [%s]', $scheduled_action_name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | delete $config->{tasks}->{$task}->{autoscaling}->{scheduled}->{$scheduled_action}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | if ( !keys %{ $config->{tasks}->{$task}->{autoscaling}->{scheduled} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | delete $config->{tasks}->{$task}->{autoscaling}->{scheduled}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | $self->update_config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | return $SUCCESS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | sub cmd_delete_autoscaling_policy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_delete_autoscaling_policy: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my ( $config, $tasks ) = $self->common_args(qw(config tasks)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | my ($task_name) = $self->get_default_service_name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | ▶ | croak sprintf "usage: delete-autoscaling-policy task-name\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | if !$task_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | my $app_autoscaling = $self->fetch_application_autoscaling; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | croak sprintf "ERROR: no scaling policy defined for: [%s]\n", $task_name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | if !exists $config->{tasks}->{$task_name}->{autoscaling}->{policy_name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my $resource_id = $self->_resource_id($task_name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my $policy_name = $config->{tasks}->{$task_name}->{autoscaling}->{policy_name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | if ( !$self->get_force ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | if ( !confirm( 'Are you sure you want to delete scaling policy: [%s]', $policy_name ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | print {*STDOUT} "Aborting...\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | return $SUCCESS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | $app_autoscaling->delete_scaling_policy( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | resource_id => $resource_id, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | policy_name => $policy_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | scalable_dimension => 'ecs:service:DesiredCount', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | service_namespace => 'ecs', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $app_autoscaling->check_result( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | { message => 'ERROR: could not delete scaling policy: [%s]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | params => [$policy_name], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | regexp => qr/no\sscaling\spolicy\sfound/xsmi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | foreach (qw(policy_arn policy_name cpu requests scale_in_cooldown scale_out_cooldown max_capacity min_capacity)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | delete $config->{tasks}->{$task_name}->{autoscaling}->{$_}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | if ( !keys %{ $config->{tasks}->{$task_name}->{autoscaling} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | delete $config->{tasks}->{$task_name}->{autoscaling}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $self->update_config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | return $SUCCESS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | sub _get_autoscaling_task_name { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_autoscaling_task_name: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | my ( $self, $tasks ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my (@args) = $self->get_args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $possible_task_name = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | return ( $possible_task_name, @args ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | ▶ | if $tasks->{$possible_task_name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my ( $task_name, $err ) = grep { $tasks->{$_}->{type} =~ /^(daemon|https?)$/xsm } keys %{$tasks}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | croak "ERROR: You need to select which task to apply autoscaling to\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | if $err; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | return ( $task_name, $possible_task_name, @args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | sub cmd_add_scheduled_action { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_add_scheduled_action: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my $tasks = $self->get_config->{tasks}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | my ( $task_name, @args ) = $self->_get_autoscaling_task_name($tasks); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | croak | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | "usage: add-scheduled-action [task] name start-time end-time days min-capacity max-capacity (ex: 00:18 00:02 MON-FRI 2/1 2/2)\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | if @args != 6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | my $schedule_name = shift @args; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | my $scheduled = $tasks->{$task_name}->{autoscaling}->{scheduled} // {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$tasks->{$task_name}{"autoscaling"}{"scheduled"} // {}
MC/DC0%0/1
$tasks->{$task_name}{"autoscaling"}{"scheduled"} // {}
$tasks->{$task_name}{"autoscaling"}{"scheduled"}
Truth table0%0/2
A
A= $tasks->{$task_name}{"autoscaling"}{"scheduled"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | # plan will verify these values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $scheduled->{$schedule_name} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | start_time => $args[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | end_time => $args[1], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | days => $args[2], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | min_capacity => $args[3], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | max_capacity => $args[4], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | my $autoscaling_config = App::FargateStack::AutoscalingConfig->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | config => $tasks->{$task_name}->{autoscaling}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | task_name => $task_name | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | $self->update_config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | print {*STDOUT} sprintf "Scheduled action: [%s] added to your configuration. Run plan to verify the configuration.\n", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | $schedule_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | return $SUCCESS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | ▶ | sub cmd_add_scaling_policy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
cmd_add_scaling_policy: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | ######################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $tasks = $self->get_config->{tasks}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | my ( $task_name, @args ) = $self->_get_autoscaling_task_name($tasks); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | croak | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
@args == 2 || @args == 4 || @args == 6 and $args[0] =~ /^(?:cpu|requests)$/msx
@args == 2 or @args == 4 or @args == 6
@args == 2 or @args == 4
MC/DC0%0/4
@args == 2 || @args == 4 || @args == 6 and $args[0] =~ /^(?:cpu|requests)$/msx
@args == 2
@args == 4
@args == 6
$args[0] =~ /^(?:cpu|requests)$/msx
Truth table0%0/7
A or B or C and D
A= @args == 2B= @args == 4C= @args == 6D= $args[0] =~ /^(?:cpu|requests)$/msx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | "usage: add-scaling-policy [task] cpu|requests metric-value [min_capacity max_capacity [scale_out_cooldown scale_in_cooldown]]\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | if !( @args == 2 || @args == 4 || @args == 6 ) || $args[0] !~ /^(?:cpu|requests)$/xsm; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | my $autoscaling_config = App::FargateStack::AutoscalingConfig->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | config => $tasks->{$task_name}->{autoscaling}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | task_name => $task_name, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | metric => sprintf( '%s:%s', @args[ 0, 1 ] ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | min_capacity => $args[2], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | max_capacity => $args[3], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | scale_out_cooldown => $args[4], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | scale_in_cooldown => $args[5], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | policy_name => $self->create_default( 'autoscaling-policy-name', $task_name ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | print {*STDOUT} sprintf "Scaling policy: [%s] added to your configuration. Run plan to verify the configuration.\n", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | $autoscaling_config->get_policy_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $self->update_config; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | return $SUCCESS; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||