@@ -160,9 +160,7 @@ function create_eks() {
160160 eksctl create cluster --timeout=$EKSCTL_TIMEOUT --install-neuron-plugin=false -f /workspace/eks.yaml
161161 echo
162162
163- if [ " ${CORTEX_SPOT,,} " == " true" ]; then
164- suspend_spot_az_rebalance
165- fi
163+ suspend_az_rebalance
166164
167165 write_kubeconfig
168166}
@@ -325,14 +323,20 @@ function resize_nodegroup() {
325323 fi
326324}
327325
328- function suspend_spot_az_rebalance() {
329- asg_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\` )]" )
330- asg_name=$( echo " $asg_info " | jq -r ' first | .AutoScalingGroupName' )
331- if [ " $asg_name " = " " ] || [ " $asg_name " = " null" ]; then
332- echo -e " unable to find autoscaling group name from info:\n$asg_info "
333- exit 1
326+ function suspend_az_rebalance() {
327+ 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\` )]" )
328+ asg_on_demand_length=$( echo " $asg_on_demand_info " | jq -r ' length' )
329+ if (( "$asg_on_demand_length " > "0 " )) ; then
330+ asg_on_demand_name=$( echo " $asg_on_demand_info " | jq -r ' first | .AutoScalingGroupName' )
331+ aws autoscaling suspend-processes --region $CORTEX_REGION --auto-scaling-group-name $asg_on_demand_name --scaling-processes AZRebalance
332+ fi
333+
334+ 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\` )]" )
335+ asg_spot_length=$( echo " $asg_spot_info " | jq -r ' length' )
336+ if (( "$asg_spot_length " > "0 " )) ; then
337+ asg_spot_name=$( echo " $asg_spot_info " | jq -r ' first | .AutoScalingGroupName' )
338+ aws autoscaling suspend-processes --region $CORTEX_REGION --auto-scaling-group-name $asg_spot_name --scaling-processes AZRebalance
334339 fi
335- aws autoscaling suspend-processes --region $CORTEX_REGION --auto-scaling-group-name $asg_name --scaling-processes AZRebalance
336340}
337341
338342function create_vpc_link() {
0 commit comments