Skip to content

Commit e7bacc5

Browse files
authored
Fix cluster configure command (#1957)
1 parent 793bfca commit e7bacc5

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

cli/cmd/lib_cluster_config_aws.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"github.com/cortexlabs/cortex/pkg/consts"
2626
"github.com/cortexlabs/cortex/pkg/lib/aws"
2727
cr "github.com/cortexlabs/cortex/pkg/lib/configreader"
28+
"github.com/cortexlabs/cortex/pkg/lib/console"
2829
"github.com/cortexlabs/cortex/pkg/lib/errors"
2930
"github.com/cortexlabs/cortex/pkg/lib/files"
3031
"github.com/cortexlabs/cortex/pkg/lib/maps"
@@ -33,6 +34,7 @@ import (
3334
s "github.com/cortexlabs/cortex/pkg/lib/strings"
3435
"github.com/cortexlabs/cortex/pkg/lib/table"
3536
"github.com/cortexlabs/cortex/pkg/types/clusterconfig"
37+
"github.com/cortexlabs/yaml"
3638
)
3739

3840
var _cachedClusterConfigRegex = regexp.MustCompile(`^cluster_\S+\.yaml$`)
@@ -204,6 +206,15 @@ func getConfigureClusterConfig(cachedClusterConfig clusterconfig.Config, cluster
204206
return nil, clusterconfig.ErrorConfigCannotBeChangedOnUpdate()
205207
}
206208

209+
yamlBytes, err := yaml.Marshal(userClusterConfig)
210+
if err != nil {
211+
return nil, err
212+
}
213+
yamlString := string(yamlBytes)
214+
215+
fmt.Println(console.Bold("cluster config:"))
216+
fmt.Println(yamlString)
217+
207218
if !disallowPrompt {
208219
exitMessage := fmt.Sprintf("cluster configuration can be modified via the cluster config file; see https://docs.cortex.dev/v/%s/ for more information", consts.CortexVersionMinor)
209220
prompt.YesOrExit(fmt.Sprintf("your cluster named \"%s\" in %s will be updated according to the configuration above, are you sure you want to continue?", userClusterConfig.ClusterName, userClusterConfig.Region), "", exitMessage)

manager/install.sh

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -342,19 +342,25 @@ function restart_operator() {
342342
function resize_nodegroup() {
343343
eksctl get nodegroup --cluster=$CORTEX_CLUSTER_NAME --region=$CORTEX_REGION -o json > nodegroups.json
344344
ng_len=$(cat nodegroups.json | jq -r length)
345+
cluster_config_ng_len=$(cat /in/cluster_${CORTEX_CLUSTER_NAME}_${CORTEX_REGION}.yaml | yq -r .node_groups | yq -r length)
345346
num_resizes=0
346347

347-
for idx in $(seq 0 $(($ng_len-1))); do
348-
stack_ng=$(cat nodegroups.json | jq -r .[$idx].Name)
349-
if [ "$stack_ng" = "cx-operator" ]; then
350-
continue
351-
fi
352-
348+
for idx in $(seq 0 $(($cluster_config_ng_len-1))); do
353349
config_ng=$(cat /in/cluster_${CORTEX_CLUSTER_NAME}_${CORTEX_REGION}.yaml | yq -r .node_groups[$idx].name)
354350

355-
desired=$(cat nodegroups.json | jq -r .[$idx].DesiredCapacity)
356-
existing_min=$(cat nodegroups.json | jq -r .[$idx].MinSize)
357-
existing_max=$(cat nodegroups.json | jq -r .[$idx].MaxSize)
351+
for eks_idx in $(seq 0 $(($ng_len-1))); do
352+
stack_ng=$(cat nodegroups.json | jq -r .[$eks_idx].Name)
353+
if [ "$stack_ng" = "cx-operator" ]; then
354+
continue
355+
fi
356+
if [[ "$stack_ng" == *"$config_ng" ]]; then
357+
break
358+
fi
359+
done
360+
361+
desired=$(cat nodegroups.json | jq -r .[$eks_idx].DesiredCapacity)
362+
existing_min=$(cat nodegroups.json | jq -r .[$eks_idx].MinSize)
363+
existing_max=$(cat nodegroups.json | jq -r .[$eks_idx].MaxSize)
358364
updating_min=$(cat /in/cluster_${CORTEX_CLUSTER_NAME}_${CORTEX_REGION}.yaml | yq -r .node_groups[$idx].min_instances)
359365
updating_max=$(cat /in/cluster_${CORTEX_CLUSTER_NAME}_${CORTEX_REGION}.yaml | yq -r .node_groups[$idx].max_instances)
360366
if [ $updating_min = "null" ]; then

0 commit comments

Comments
 (0)