Skip to content

Commit ae9cb2f

Browse files
vishalbolludeliahu
authored andcommitted
Fix cluster update (#787)
(cherry picked from commit 70a09d5)
1 parent 3a08b08 commit ae9cb2f

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

manager/install.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,18 @@ function ensure_eks() {
8080

8181
# Check for change in min/max instances
8282
asg_on_demand_info=$(aws autoscaling describe-auto-scaling-groups --region $CORTEX_REGION --query "AutoScalingGroups[?contains(Tags[?Key==\`alpha.eksctl.io/cluster-name\`].Value, \`$CORTEX_CLUSTER_NAME\`)]|[?contains(Tags[?Key==\`alpha.eksctl.io/nodegroup-name\`].Value, \`ng-cortex-worker-on-demand\`)]")
83-
asg_on_demand_name=$(echo "$asg_on_demand_info" | jq -r 'first | .AutoScalingGroupName')
83+
asg_on_demand_length=$(echo "$asg_on_demand_info" | jq -r 'length')
84+
asg_on_demand_name=""
85+
if (( "$asg_on_demand_length" > "0" )); then
86+
asg_on_demand_name=$(echo "$asg_on_demand_info" | jq -r 'first | .AutoScalingGroupName')
87+
fi
8488

8589
asg_spot_info=$(aws autoscaling describe-auto-scaling-groups --region $CORTEX_REGION --query "AutoScalingGroups[?contains(Tags[?Key==\`alpha.eksctl.io/cluster-name\`].Value, \`$CORTEX_CLUSTER_NAME\`)]|[?contains(Tags[?Key==\`alpha.eksctl.io/nodegroup-name\`].Value, \`ng-cortex-worker-spot\`)]")
86-
asg_spot_name=$(echo "$asg_spot_info" | jq -r 'first | .AutoScalingGroupName')
90+
asg_spot_length=$(echo "$asg_spot_info" | jq -r 'length')
91+
asg_spot_name=""
92+
if (( "$asg_spot_length" > "0" )); then
93+
asg_spot_name=$(echo "$asg_spot_info" | jq -r 'first | .AutoScalingGroupName')
94+
fi
8795

8896
if [[ -z $asg_spot_name ]]; then
8997
asg_min_size=$(echo "$asg_on_demand_info" | jq -r 'first | .MinSize')
@@ -93,9 +101,14 @@ function ensure_eks() {
93101
asg_max_size=$(echo "$asg_spot_info" | jq -r 'first | .MaxSize')
94102
fi
95103

104+
if [[ -z "$asg_spot_name" ]] && [[ -z "$asg_on_demand_name" ]]; then
105+
echo "error: unable to find valid autoscaling groups"
106+
exit 1
107+
fi
108+
96109
if [ "$asg_min_size" != "$CORTEX_MIN_INSTANCES" ]; then
97110
echo -n "○ updating min instances to $CORTEX_MIN_INSTANCES "
98-
111+
# only update min if on demand nodegroup exists and on demand nodegroup is not a backup
99112
if [[ -n $asg_on_demand_name ]] && [[ "$CORTEX_SPOT_CONFIG_ON_DEMAND_BACKUP" != "True" ]]; then
100113
aws autoscaling update-auto-scaling-group --region $CORTEX_REGION --auto-scaling-group-name $asg_on_demand_name --min-size=$CORTEX_MIN_INSTANCES
101114
fi

0 commit comments

Comments
 (0)