Skip to content

Commit 2da4b75

Browse files
committed
Added a validation to avoid failing when it's the first deployment and deregister_from_elb.sh was not run on ApplicationStop
1 parent d8c7a45 commit 2da4b75

File tree

2 files changed

+25
-11
lines changed

2 files changed

+25
-11
lines changed

load-balancing/elb/deregister_from_elb.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ fi
5151

5252
msg "Instance is not part of an ASG, trying with ELB..."
5353

54+
set_flag "dereg" "true"
55+
5456
if [ -z "$ELB_LIST" ]; then
5557
error_exit "ELB_LIST is empty. Must have at least one load balancer to deregister from, or \"_all_\", \"_any_\" values."
5658
elif [ "${ELB_LIST}" = "_all_" ]; then

load-balancing/elb/register_with_elb.sh

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,31 @@ msg "Instance is not part of an ASG, continuing with ELB"
5454
if [ -z "$ELB_LIST" ]; then
5555
error_exit "ELB_LIST is empty. Must have at least one load balancer to register to, or \"_all_\", \"_any_\" values."
5656
elif [ "${ELB_LIST}" = "_all_" ]; then
57-
msg "Finding all the ELBs that this instance was previously registered to"
58-
if ! ELB_LIST=$(get_flag "ELBs"); then
59-
error_exit "$FLAGFILE doesn't exist or is unreadble"
60-
elif [ -z $ELB_LIST ]; then
61-
error_exit "Couldn't find any. Must have at least one load balancer to register to."
57+
if [ "$(get_flag "dereg")" = "true" ]; then
58+
msg "Finding all the ELBs that this instance was previously registered to"
59+
if ! ELB_LIST=$(get_flag "ELBs"); then
60+
error_exit "$FLAGFILE doesn't exist or is unreadble"
61+
elif [ -z $ELB_LIST ]; then
62+
error_exit "Couldn't find any. Must have at least one load balancer to register to."
63+
fi
64+
else
65+
msg "Assuming this is the first deployment and ELB_LIST=_all_ so finishing successfully without registering."
66+
finish_msg
67+
exit 0
6268
fi
6369
elif [ "${ELB_LIST}" = "_any_" ]; then
64-
msg "Finding all the ELBs that this instance was previously registered to"
65-
if ! ELB_LIST=$(get_flag "ELBs"); then
66-
error_exit "$FLAGFILE doesn't exist or is unreadble"
67-
elif [ -z $ELB_LIST ]; then
68-
msg "Couldn't find any, but ELB_LIST=any so finishing successfully without registering."
69-
remove_flagfile
70+
if [ "$(get_flag "dereg")" = "true" ]; then
71+
msg "Finding all the ELBs that this instance was previously registered to"
72+
if ! ELB_LIST=$(get_flag "ELBs"); then
73+
error_exit "$FLAGFILE doesn't exist or is unreadble"
74+
elif [ -z $ELB_LIST ]; then
75+
msg "Couldn't find any, but ELB_LIST=_any_ so finishing successfully without registering."
76+
remove_flagfile
77+
finish_msg
78+
exit 0
79+
fi
80+
else
81+
msg "Assuming this is the first deployment and ELB_LIST=_any_ so finishing successfully without registering."
7082
finish_msg
7183
exit 0
7284
fi

0 commit comments

Comments
 (0)