@@ -160,9 +160,7 @@ function create_eks() {
160
160
eksctl create cluster --timeout=$EKSCTL_TIMEOUT --install-neuron-plugin=false -f /workspace/eks.yaml
161
161
echo
162
162
163
- if [ " ${CORTEX_SPOT,,} " == " true" ]; then
164
- suspend_spot_az_rebalance
165
- fi
163
+ suspend_az_rebalance
166
164
167
165
write_kubeconfig
168
166
}
@@ -325,14 +323,20 @@ function resize_nodegroup() {
325
323
fi
326
324
}
327
325
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
334
339
fi
335
- aws autoscaling suspend-processes --region $CORTEX_REGION --auto-scaling-group-name $asg_name --scaling-processes AZRebalance
336
340
}
337
341
338
342
function create_vpc_link() {
0 commit comments