Skip to content

Commit 9d55660

Browse files
committed
local return code doesn't propagate
1 parent 9cd81d4 commit 9d55660

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

load-balancing/elb/common_functions.sh

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ resume_processes() {
183183
local -a to_resume
184184

185185
for p in ${processes[@]}; do
186-
if ! local tmp_flag_value=$(get_flag "$p"); then
186+
local tmp_flag_file
187+
if ! tmp_flag_value=$(get_flag "$p"); then
187188
error_exit "$FLAGFILE doesn't exist or is unreadable"
188189
elif [ ! "$tmp_flag_value" = "true" ] ; then
189190
to_resume=("${to_resume[@]}" "$p")
@@ -232,7 +233,8 @@ autoscaling_group_name() {
232233
local instance_id=$1
233234

234235
# This operates under the assumption that instances are only ever part of a single ASG.
235-
local autoscaling_name=$($AWS_CLI autoscaling describe-auto-scaling-instances \
236+
local autoscaling_name
237+
autoscaling_name=$($AWS_CLI autoscaling describe-auto-scaling-instances \
236238
--instance-ids $instance_id \
237239
--output text \
238240
--query AutoScalingInstances[0].AutoScalingGroupName | tr -d '\n\r')
@@ -259,7 +261,8 @@ autoscaling_enter_standby() {
259261
local asg_name=${2}
260262

261263
msg "Checking if this instance has already been moved in the Standby state"
262-
local instance_state=$(get_instance_state_asg $instance_id)
264+
local instance_state
265+
instance_state=$(get_instance_state_asg $instance_id)
263266
if [ $? != 0 ]; then
264267
msg "Unable to get this instance's lifecycle state."
265268
return 1
@@ -345,7 +348,8 @@ autoscaling_exit_standby() {
345348
local asg_name=${2}
346349

347350
msg "Checking if this instance has already been moved out of Standby state"
348-
local instance_state=$(get_instance_state_asg $instance_id)
351+
local instance_state
352+
instance_state=$(get_instance_state_asg $instance_id)
349353
if [ $? != 0 ]; then
350354
msg "Unable to get this instance's lifecycle state."
351355
return 1
@@ -379,7 +383,8 @@ autoscaling_exit_standby() {
379383
return 1
380384
fi
381385

382-
if ! local tmp_flag_value=$(get_flag "asgmindecremented"); then
386+
local tmp_flag_value
387+
if ! tmp_flag_value=$(get_flag "asgmindecremented"); then
383388
error_exit "$FLAGFILE doesn't exist or is unreadable"
384389
elif [ "$tmp_flag_value" = "true" ]; then
385390
local min_desired=$($AWS_CLI autoscaling describe-auto-scaling-groups \
@@ -423,7 +428,8 @@ autoscaling_exit_standby() {
423428
get_instance_state_asg() {
424429
local instance_id=$1
425430

426-
local state=$($AWS_CLI autoscaling describe-auto-scaling-instances \
431+
local state
432+
state=$($AWS_CLI autoscaling describe-auto-scaling-instances \
427433
--instance-ids $instance_id \
428434
--query \"AutoScalingInstances[?InstanceId == \'$instance_id\'].LifecycleState \| [0]\" \
429435
--output text)
@@ -543,7 +549,8 @@ get_instance_health_elb() {
543549
# If describe-instance-health for this instance returns an error, then it's not part of
544550
# this ELB. But, if the call was successful let's still double check that the status is
545551
# valid.
546-
local instance_status=$($AWS_CLI elb describe-instance-health \
552+
local instance_status
553+
instance_status=$($AWS_CLI elb describe-instance-health \
547554
--load-balancer-name $elb_name \
548555
--instances $instance_id \
549556
--query \'InstanceStates[].State\' \
@@ -573,7 +580,8 @@ validate_elb() {
573580
local elb_name=$2
574581

575582
# Get the list of active instances for this LB.
576-
local elb_instances=$($AWS_CLI elb describe-load-balancers \
583+
local elb_instances
584+
elb_instances=$($AWS_CLI elb describe-load-balancers \
577585
--load-balancer-name $elb_name \
578586
--query \'LoadBalancerDescriptions[*].Instances[*].InstanceId\' \
579587
--output text)
@@ -583,7 +591,8 @@ validate_elb() {
583591
fi
584592

585593
msg "Checking health of '$instance_id' as known by ELB '$elb_name'"
586-
local instance_health=$(get_instance_health_elb $instance_id $elb_name)
594+
local instance_health
595+
instance_health=$(get_instance_health_elb $instance_id $elb_name)
587596
if [ $? != 0 ]; then
588597
return 1
589598
fi

0 commit comments

Comments
 (0)