Skip to content

Fix cluster configure command #1957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions cli/cmd/lib_cluster_config_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/cortexlabs/cortex/pkg/consts"
"github.com/cortexlabs/cortex/pkg/lib/aws"
cr "github.com/cortexlabs/cortex/pkg/lib/configreader"
"github.com/cortexlabs/cortex/pkg/lib/console"
"github.com/cortexlabs/cortex/pkg/lib/errors"
"github.com/cortexlabs/cortex/pkg/lib/files"
"github.com/cortexlabs/cortex/pkg/lib/maps"
Expand All @@ -33,6 +34,7 @@ import (
s "github.com/cortexlabs/cortex/pkg/lib/strings"
"github.com/cortexlabs/cortex/pkg/lib/table"
"github.com/cortexlabs/cortex/pkg/types/clusterconfig"
"github.com/cortexlabs/yaml"
)

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

yamlBytes, err := yaml.Marshal(userClusterConfig)
if err != nil {
return nil, err
}
yamlString := string(yamlBytes)

fmt.Println(console.Bold("cluster config:"))
fmt.Println(yamlString)

if !disallowPrompt {
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)
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)
Expand Down
18 changes: 12 additions & 6 deletions manager/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -342,16 +342,22 @@ function restart_operator() {
function resize_nodegroup() {
eksctl get nodegroup --cluster=$CORTEX_CLUSTER_NAME --region=$CORTEX_REGION -o json > nodegroups.json
ng_len=$(cat nodegroups.json | jq -r length)
cluster_config_ng_len=$(cat /in/cluster_${CORTEX_CLUSTER_NAME}_${CORTEX_REGION}.yaml | yq -r .node_groups | yq -r length)
num_resizes=0

for idx in $(seq 0 $(($ng_len-1))); do
stack_ng=$(cat nodegroups.json | jq -r .[$idx].Name)
if [ "$stack_ng" = "cx-operator" ]; then
continue
fi

for idx in $(seq 0 $(($cluster_config_ng_len-1))); do
config_ng=$(cat /in/cluster_${CORTEX_CLUSTER_NAME}_${CORTEX_REGION}.yaml | yq -r .node_groups[$idx].name)

for eks_idx in $(seq 0 $(($ng_len-1))); do
stack_ng=$(cat nodegroups.json | jq -r .[$eks_idx].Name)
if [ "$stack_ng" = "cx-operator" ]; then
continue
fi
if [[ "$stack_ng" == *"$config_ng" ]]; then
break
fi
done

desired=$(cat nodegroups.json | jq -r .[$idx].DesiredCapacity)
existing_min=$(cat nodegroups.json | jq -r .[$idx].MinSize)
existing_max=$(cat nodegroups.json | jq -r .[$idx].MaxSize)
Expand Down