@@ -346,15 +346,15 @@ var _clusterScaleCmd = &cobra.Command{
346
346
}
347
347
348
348
clusterConfig := refreshCachedClusterConfig (* awsClient , accessConfig , true )
349
- clusterConfig , err = updateNodeGroupScale (clusterConfig , _flagClusterScaleNodeGroup , scaleMinIntances , scaleMaxInstances , _flagClusterDisallowPrompt )
349
+ clusterConfig , ngIndex , err : = updateNodeGroupScale (clusterConfig , _flagClusterScaleNodeGroup , scaleMinIntances , scaleMaxInstances , _flagClusterDisallowPrompt )
350
350
if err != nil {
351
351
exit .Error (err )
352
352
}
353
353
354
354
out , exitCode , err := runManagerWithClusterConfig ("/root/install.sh --update" , & clusterConfig , awsClient , nil , nil , []string {
355
355
"CORTEX_SCALING_NODEGROUP=" + _flagClusterScaleNodeGroup ,
356
- "CORTEX_SCALING_MIN_INSTANCES=" + s .Int64 (_flagClusterScaleMinInstances ),
357
- "CORTEX_SCALING_MAX_INSTANCES=" + s .Int64 (_flagClusterScaleMaxInstances ),
356
+ "CORTEX_SCALING_MIN_INSTANCES=" + s .Int64 (clusterConfig . NodeGroups [ ngIndex ]. MinInstances ),
357
+ "CORTEX_SCALING_MAX_INSTANCES=" + s .Int64 (clusterConfig . NodeGroups [ ngIndex ]. MaxInstances ),
358
358
})
359
359
if err != nil {
360
360
exit .Error (err )
@@ -1023,11 +1023,10 @@ func refreshCachedClusterConfig(awsClient aws.Client, accessConfig *clusterconfi
1023
1023
return * refreshedClusterConfig
1024
1024
}
1025
1025
1026
- func updateNodeGroupScale (clusterConfig clusterconfig.Config , targetNg string , desiredMinReplicas , desiredMaxReplicas * int64 , disallowPrompt bool ) (clusterconfig.Config , error ) {
1026
+ func updateNodeGroupScale (clusterConfig clusterconfig.Config , targetNg string , desiredMinReplicas , desiredMaxReplicas * int64 , disallowPrompt bool ) (clusterconfig.Config , int , error ) {
1027
1027
clusterName := clusterConfig .ClusterName
1028
1028
region := clusterConfig .Region
1029
1029
1030
- ngFound := false
1031
1030
availableNodeGroups := []string {}
1032
1031
for idx , ng := range clusterConfig .NodeGroups {
1033
1032
if ng == nil {
@@ -1048,13 +1047,13 @@ func updateNodeGroupScale(clusterConfig clusterconfig.Config, targetNg string, d
1048
1047
}
1049
1048
1050
1049
if minReplicas < 0 {
1051
- return clusterconfig.Config {}, ErrorMinInstancesLowerThan (0 )
1050
+ return clusterconfig.Config {}, 0 , ErrorMinInstancesLowerThan (0 )
1052
1051
}
1053
1052
if maxReplicas < 0 {
1054
- return clusterconfig.Config {}, ErrorMaxInstancesLowerThan (0 )
1053
+ return clusterconfig.Config {}, 0 , ErrorMaxInstancesLowerThan (0 )
1055
1054
}
1056
1055
if minReplicas > maxReplicas {
1057
- return clusterconfig.Config {}, ErrorMinInstancesGreaterThanMaxInstances (minReplicas , maxReplicas )
1056
+ return clusterconfig.Config {}, 0 , ErrorMinInstancesGreaterThanMaxInstances (minReplicas , maxReplicas )
1058
1057
}
1059
1058
1060
1059
if ng .MinInstances == minReplicas && ng .MaxInstances == maxReplicas {
@@ -1080,16 +1079,11 @@ func updateNodeGroupScale(clusterConfig clusterconfig.Config, targetNg string, d
1080
1079
1081
1080
clusterConfig .NodeGroups [idx ].MinInstances = minReplicas
1082
1081
clusterConfig .NodeGroups [idx ].MaxInstances = maxReplicas
1083
- ngFound = true
1084
- break
1082
+ return clusterConfig , idx , nil
1085
1083
}
1086
1084
}
1087
1085
1088
- if ! ngFound {
1089
- return clusterconfig.Config {}, ErrorNodeGroupNotFound (targetNg , clusterName , region , availableNodeGroups )
1090
- }
1091
-
1092
- return clusterConfig , nil
1086
+ return clusterconfig.Config {}, 0 , ErrorNodeGroupNotFound (targetNg , clusterName , region , availableNodeGroups )
1093
1087
}
1094
1088
1095
1089
func createS3BucketIfNotFound (awsClient * aws.Client , bucket string , tags map [string ]string ) error {
0 commit comments