From 2292440c05be1ec9198fc976444a4e1851956e04 Mon Sep 17 00:00:00 2001 From: Matt Clark Date: Fri, 17 Jul 2026 18:43:03 -0700 Subject: [PATCH 1/4] ROSAENG-62105 | fix: require utilization threshold strictly between 0 and 1 Align PercentageValidator bounds with the cluster-autoscaler-operator webhook and OCP documentation. Reject 0, 1, and NaN as invalid values. Fix error strings to comply with Go staticcheck ST1005 conventions. Update flag help text and all affected test expectations. --- cmd/create/autoscaler/cmd_test.go | 1 + cmd/edit/autoscaler/cmd_test.go | 1 + pkg/clusterautoscaler/flags.go | 42 ++++---- pkg/ocm/validators.go | 17 ++-- pkg/ocm/validators_test.go | 12 +++ tests/e2e/rosa_autoscaler_test.go | 164 +++++++++++++++--------------- tests/e2e/test_rosacli_cluster.go | 26 ++--- 7 files changed, 139 insertions(+), 124 deletions(-) diff --git a/cmd/create/autoscaler/cmd_test.go b/cmd/create/autoscaler/cmd_test.go index f8060b7c85..30320a352e 100644 --- a/cmd/create/autoscaler/cmd_test.go +++ b/cmd/create/autoscaler/cmd_test.go @@ -182,6 +182,7 @@ var _ = Describe("create autoscaler", func() { VerifyJQ(`.resource_limits.cores.max`, 0.0), )) args := &clusterautoscaler.AutoscalerArgs{} + args.ScaleDown.UtilizationThreshold = 0.5 args.LogVerbosity = 3 args.ResourceLimits.MaxNodesTotal = 20 runner := CreateAutoscalerRunner(args) diff --git a/cmd/edit/autoscaler/cmd_test.go b/cmd/edit/autoscaler/cmd_test.go index 7ce8e55fe6..b1c141524c 100644 --- a/cmd/edit/autoscaler/cmd_test.go +++ b/cmd/edit/autoscaler/cmd_test.go @@ -157,6 +157,7 @@ var _ = Describe("edit autoscaler", func() { VerifyJQ(`.resource_limits.cores.max`, 30.0), )) args := &clusterautoscaler.AutoscalerArgs{} + args.ScaleDown.UtilizationThreshold = 0.5 args.LogVerbosity = 1 args.ResourceLimits.MaxNodesTotal = 20 runner := EditAutoscalerRunner(args) diff --git a/pkg/clusterautoscaler/flags.go b/pkg/clusterautoscaler/flags.go index d5bd6ce109..f85fc16d86 100644 --- a/pkg/clusterautoscaler/flags.go +++ b/pkg/clusterautoscaler/flags.go @@ -244,7 +244,7 @@ func AddClusterAutoscalerFlags(cmd *cobra.Command, prefix string) *AutoscalerArg fmt.Sprintf("%s%s", prefix, scaleDownUtilizationThresholdFlag), 0.5, fmt.Sprintf("Node utilization level, defined as sum of requested resources divided by capacity, "+ - "below which a node can be considered for scale down. Value should be between 0 and 1. %s", + "below which a node can be considered for scale down. Value must be greater than 0 and less than 1. %s", classicOnlyHelpMsg), ) @@ -365,7 +365,7 @@ func GetAutoscalerOptions( } } if err := ocm.NonNegativeInt32Validator(result.LogVerbosity); err != nil { - return nil, fmt.Errorf("Error validating log-verbosity: %s", err) + return nil, fmt.Errorf("error validating log-verbosity: %s", err) } if interactive.Enabled() && !cmd.Changed(fmt.Sprintf("%s%s", prefix, balancingIgnoredLabelsFlag)) { @@ -387,7 +387,7 @@ func GetAutoscalerOptions( } } if err := ocm.ValidateBalancingIgnoredLabels(strings.Join(result.BalancingIgnoredLabels, ",")); err != nil { - return nil, fmt.Errorf("Error validating balancing-ignored-labels: %s", err) + return nil, fmt.Errorf("error validating balancing-ignored-labels: %s", err) } if interactive.Enabled() && !cmd.Changed(fmt.Sprintf("%s%s", prefix, ignoreDaemonsetsUtilizationFlag)) { @@ -436,7 +436,7 @@ func GetAutoscalerOptions( } } if err := ocm.NonNegativeInt32Validator(result.MaxPodGracePeriod); err != nil { - return nil, fmt.Errorf("Error validating max-pod-grace-period: %s", err) + return nil, fmt.Errorf("error validating max-pod-grace-period: %s", err) } if interactive.Enabled() && !cmd.Changed(fmt.Sprintf("%s%s", prefix, podPriorityThresholdFlag)) { @@ -470,7 +470,7 @@ func GetAutoscalerOptions( } } if err := ocm.NonNegativeInt32Validator(result.ResourceLimits.MaxNodesTotal); err != nil { - return nil, fmt.Errorf("Error validating max-nodes-total: %s", err) + return nil, fmt.Errorf("error validating max-nodes-total: %s", err) } if autoscalerValidationArgs != nil && !autoscalerValidationArgs.IsHostedCp { @@ -489,7 +489,7 @@ func GetAutoscalerOptions( } } if err = ocm.NonNegativeInt32Validator(result.ResourceLimits.Cores.Min); err != nil { - return nil, fmt.Errorf("Error validating min-cores: %s", err) + return nil, fmt.Errorf("error validating min-cores: %s", err) } if interactive.Enabled() && !cmd.Changed(fmt.Sprintf("%s%s", prefix, maxCoresFlag)) { @@ -508,11 +508,11 @@ func GetAutoscalerOptions( } } if err := ocm.NonNegativeInt32Validator(result.ResourceLimits.Cores.Max); err != nil { - return nil, fmt.Errorf("Error validating max-cores: %s", err) + return nil, fmt.Errorf("error validating max-cores: %s", err) } if err := getValidMaxRangeValidator(result.ResourceLimits.Cores.Min)(result.ResourceLimits.Cores.Max); err != nil { - return nil, fmt.Errorf("Error validating cores range: %s", err) + return nil, fmt.Errorf("error validating cores range: %s", err) } if interactive.Enabled() && !cmd.Changed(fmt.Sprintf("%s%s", prefix, minMemoryFlag)) { @@ -530,7 +530,7 @@ func GetAutoscalerOptions( } } if err := ocm.NonNegativeInt32Validator(result.ResourceLimits.Memory.Min); err != nil { - return nil, fmt.Errorf("Error validating min-memory: %s", err) + return nil, fmt.Errorf("error validating min-memory: %s", err) } if interactive.Enabled() && !cmd.Changed(fmt.Sprintf("%s%s", prefix, maxMemoryFlag)) { @@ -549,11 +549,11 @@ func GetAutoscalerOptions( } } if err := ocm.NonNegativeInt32Validator(result.ResourceLimits.Memory.Max); err != nil { - return nil, fmt.Errorf("Error validating max-memory: %s", err) + return nil, fmt.Errorf("error validating max-memory: %s", err) } if err := getValidMaxRangeValidator(result.ResourceLimits.Memory.Min)(result.ResourceLimits.Memory.Max); err != nil { - return nil, fmt.Errorf("Error validating memory range: %s", err) + return nil, fmt.Errorf("error validating memory range: %s", err) } if interactive.Enabled() && !cmd.Changed(fmt.Sprintf("%s%s", prefix, gpuLimitFlag)) { @@ -622,7 +622,7 @@ func GetAutoscalerOptions( } if err := getValidMaxRangeValidator(gpuLimit.Range.Min)(gpuLimit.Range.Max); err != nil { - return nil, fmt.Errorf("Error validating GPU range: %s", err) + return nil, fmt.Errorf("error validating GPU range: %s", err) } } @@ -656,7 +656,7 @@ func GetAutoscalerOptions( } if err := ocm.PositiveDurationStringValidator(result.ScaleDown.UnneededTime); err != nil { - return nil, fmt.Errorf("Error validating unneeded-time: %s", err) + return nil, fmt.Errorf("error validating unneeded-time: %s", err) } if interactive.Enabled() && !cmd.Changed(fmt.Sprintf("%s%s", prefix, scaleDownUtilizationThresholdFlag)) { @@ -674,7 +674,7 @@ func GetAutoscalerOptions( } } if err := ocm.PercentageValidator(result.ScaleDown.UtilizationThreshold); err != nil { - return nil, fmt.Errorf("Error validating utilization-threshold: %s", err) + return nil, fmt.Errorf("error validating utilization-threshold: %s", err) } if interactive.Enabled() && !cmd.Changed(fmt.Sprintf("%s%s", prefix, scaleDownDelayAfterAddFlag)) { @@ -692,7 +692,7 @@ func GetAutoscalerOptions( } } if err := ocm.PositiveDurationStringValidator(result.ScaleDown.DelayAfterAdd); err != nil { - return nil, fmt.Errorf("Error validating delay-after-add: %s", err) + return nil, fmt.Errorf("error validating delay-after-add: %s", err) } if interactive.Enabled() && !cmd.Changed(fmt.Sprintf("%s%s", prefix, scaleDownDelayAfterDeleteFlag)) { @@ -710,7 +710,7 @@ func GetAutoscalerOptions( } } if err := ocm.PositiveDurationStringValidator(result.ScaleDown.DelayAfterDelete); err != nil { - return nil, fmt.Errorf("Error validating delay-after-delete: %s", err) + return nil, fmt.Errorf("error validating delay-after-delete: %s", err) } if interactive.Enabled() && !cmd.Changed(fmt.Sprintf("%s%s", prefix, scaleDownDelayAfterFailureFlag)) { @@ -728,7 +728,7 @@ func GetAutoscalerOptions( } } if err := ocm.PositiveDurationStringValidator(result.ScaleDown.DelayAfterFailure); err != nil { - return nil, fmt.Errorf("Error validating delay-after-failure: %s", err) + return nil, fmt.Errorf("error validating delay-after-failure: %s", err) } } @@ -867,12 +867,12 @@ func parseGPULimit(s string) (ocm.GPULimit, error) { gpuLimitMin, err := strconv.Atoi(parameters[1]) if err != nil { - return ocm.GPULimit{}, fmt.Errorf("Failed parsing '%s' into an integer: %s", parameters[1], err) + return ocm.GPULimit{}, fmt.Errorf("failed parsing '%s' into an integer: %s", parameters[1], err) } gpuLimitMax, err := strconv.Atoi(parameters[2]) if err != nil { - return ocm.GPULimit{}, fmt.Errorf("Failed parsing '%s' into an integer: %s", parameters[2], err) + return ocm.GPULimit{}, fmt.Errorf("failed parsing '%s' into an integer: %s", parameters[2], err) } return ocm.GPULimit{Type: parameters[0], Range: ocm.ResourceRange{Min: gpuLimitMin, Max: gpuLimitMax}}, nil @@ -888,11 +888,11 @@ func getValidMaxRangeValidator(min int) func(interface{}) error { max, err := strconv.Atoi(fmt.Sprintf("%v", val)) if err != nil { - return fmt.Errorf("Failed parsing '%v' to an integer number.", val) + return fmt.Errorf("failed parsing '%v' to an integer number", val) } if max < min { - return fmt.Errorf("max value must be greater or equal than min value %d.", min) + return fmt.Errorf("max value must be greater or equal than min value %d", min) } return nil diff --git a/pkg/ocm/validators.go b/pkg/ocm/validators.go index 3656056b8f..9cf28afaba 100644 --- a/pkg/ocm/validators.go +++ b/pkg/ocm/validators.go @@ -2,6 +2,7 @@ package ocm import ( "fmt" + "math" "strconv" "time" @@ -14,7 +15,7 @@ func Int32Validator(val interface{}) error { } _, err := strconv.ParseInt(fmt.Sprintf("%v", val), 10, 32) if err != nil { - return fmt.Errorf("Should provide an integer number between -2147483648 to 2147483647.") + return fmt.Errorf("should provide an integer number between -2147483648 to 2147483647") } return nil } @@ -25,11 +26,11 @@ func NonNegativeInt32Validator(val interface{}) error { } number, err := strconv.ParseInt(fmt.Sprintf("%v", val), 10, 32) if err != nil { - return fmt.Errorf("Should provide an integer number between 0 to 2147483647.") + return fmt.Errorf("should provide an integer number between 0 to 2147483647") } if number < 0 { - return fmt.Errorf("Number must be greater or equal to zero.") + return fmt.Errorf("number must be greater or equal to zero") } return nil @@ -42,7 +43,7 @@ func PositiveDurationStringValidator(val interface{}) error { input, ok := val.(string) if !ok { - return fmt.Errorf("Can only validate strings, got %v", val) + return fmt.Errorf("can only validate strings, got %v", val) } duration, err := time.ParseDuration(input) @@ -52,7 +53,7 @@ func PositiveDurationStringValidator(val interface{}) error { } if duration < 0 { - return fmt.Errorf("Only positive durations are allowed, got '%v'", val) + return fmt.Errorf("only positive durations are allowed, got '%v'", val) } return nil @@ -65,11 +66,11 @@ func PercentageValidator(val interface{}) error { number, err := strconv.ParseFloat(fmt.Sprintf("%v", val), commonUtils.MaxByteSize) if err != nil { - return fmt.Errorf("Failed parsing '%v' into a floating-point number.", val) + return fmt.Errorf("failed parsing '%v' into a floating-point number", val) } - if number > 1 || number < 0 { - return fmt.Errorf("Expecting a floating-point number between 0 and 1.") + if number >= 1 || number <= 0 || math.IsNaN(number) { + return fmt.Errorf("expecting a floating-point number greater than 0 and less than 1") } return nil diff --git a/pkg/ocm/validators_test.go b/pkg/ocm/validators_test.go index 257e67576c..77dcd44479 100644 --- a/pkg/ocm/validators_test.go +++ b/pkg/ocm/validators_test.go @@ -89,6 +89,18 @@ var _ = Describe("Input Validators", Ordered, func() { Expect(PercentageValidator("-0.1")).ToNot(BeNil()) }) + It("raises an error if got exactly 0", func() { + Expect(PercentageValidator("0")).ToNot(BeNil()) + }) + + It("raises an error if got exactly 1", func() { + Expect(PercentageValidator("1")).ToNot(BeNil()) + }) + + It("raises an error if got NaN", func() { + Expect(PercentageValidator("NaN")).ToNot(BeNil()) + }) + It("successfully parses a valid percentage value", func() { Expect(PercentageValidator("0.4")).To(BeNil()) }) diff --git a/tests/e2e/rosa_autoscaler_test.go b/tests/e2e/rosa_autoscaler_test.go index ebfb8d7086..7e949ef552 100644 --- a/tests/e2e/rosa_autoscaler_test.go +++ b/tests/e2e/rosa_autoscaler_test.go @@ -173,7 +173,7 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { By("Check Validation for max-node-provision-time") mnptValidationMap := map[string]string{ "16": "missing unit in duration", - "-17m": "Only positive durations are allowed", + "-17m": "only positive durations are allowed", "50o": "unknown unit", "10m": "value should be between 15m and 60m", "70m": "value should be between 15m and 60m", @@ -224,7 +224,7 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { By("Check Validation for max-nodes-total") mntValidationMap := map[string]string{ - "-1": "Number must be greater or equal to zero", + "-1": "number must be greater or equal to zero", "499": "exceeds the maximum allowed '500'", } for mnt, expectedMsg := range mntValidationMap { @@ -388,7 +388,7 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { "--min-memory", "0", "--max-memory", "4096", "--scale-down-enabled", - "--scale-down-utilization-threshold", "1", + "--scale-down-utilization-threshold", "0.5", "--scale-down-delay-after-delete", "10s", "--scale-down-delay-after-failure", "10s", "--gpu-limit", "nvidia.com/gpu,0,10", @@ -440,7 +440,7 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { Expect(autoscaler.ScaleDown.DelayAfterFailure).To(Equal("10s")) Expect(autoscaler.ScaleDown.Enabled).To(Equal(true)) Expect(autoscaler.ScaleDown.UnneededTime).To(Equal("10s")) - Expect(autoscaler.ScaleDown.UtilizationThreshold).To(Equal("1.000000")) + Expect(autoscaler.ScaleDown.UtilizationThreshold).To(Equal("0.500000")) } @@ -540,7 +540,7 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { "--min-memory", "0", "--max-memory", "4096", "--scale-down-enabled", - "--scale-down-utilization-threshold", "1", + "--scale-down-utilization-threshold", "0.5", "--scale-down-delay-after-delete", "10s", "--scale-down-delay-after-failure", "10s", "--gpu-limit", "nvidia.com/gpu,0,10", @@ -643,12 +643,12 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { ": strconv.ParseBool: parsing \"ty\": " + "invalid syntax": {"--skip-nodes-with-local-storage=ty"}, fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s'"+ - ": Error validating log-verbosity: "+ - "Number must be greater or "+ - "equal to zero.", clusterID): {"--log-verbosity", "-1"}, + ": error validating log-verbosity: "+ + "number must be greater or "+ + "equal to zero", clusterID): {"--log-verbosity", "-1"}, fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s'"+ - ": Error validating max-pod-grace-period: "+ - "Number must be greater or equal to zero.", + ": error validating max-pod-grace-period: "+ + "number must be greater or equal to zero", clusterID): {"--max-pod-grace-period", "-1"}, "Error: invalid argument \"ss\" for \"--pod-priority-threshold\" " + "flag: strconv.ParseInt: parsing \"ss\": " + @@ -660,8 +660,8 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { "time: unknown unit \"-\" in duration \"9-\"", clusterID): {"--max-node-provision-time", "9-"}, fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s': "+ - "Error validating max-nodes-total: "+ - "Number must be greater or equal to zero", + "error validating max-nodes-total: "+ + "number must be greater or equal to zero", clusterID): {"--max-nodes-total", "-1"}, "Error: if any flags in the group [min-cores max-cores] " + "are set they must all be set; " + @@ -670,13 +670,13 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { "are set they must all be set; " + "missing [min-cores]": {"--max-cores", "1"}, fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s': "+ - "Error validating min-cores: Number must be greater or equal to zero.", + "error validating min-cores: number must be greater or equal to zero", clusterID): {"--min-cores", "-1", "--max-cores", "1"}, fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s': "+ - "Error validating max-cores: Number must be greater or equal to zero.", + "error validating max-cores: number must be greater or equal to zero", clusterID): {"--min-cores", "1", "--max-cores", "-1"}, fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s': "+ - "Error validating cores range: max value must be greater or equal than min value 10.", + "error validating cores range: max value must be greater or equal than min value 10.", clusterID): {"--min-cores", "10", "--max-cores", "8"}, "Error: if any flags in the group [min-memory max-memory] " + "are set they must all be set; " + @@ -685,51 +685,51 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { "are set they must all be set; " + "missing [min-memory]": {"--max-memory", "1"}, fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s': "+ - "Error validating min-memory: Number must be greater or equal to zero.", + "error validating min-memory: number must be greater or equal to zero", clusterID): {"--min-memory", "-1", "--max-memory", "1"}, fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s': "+ - "Error validating max-memory: Number must be greater or equal to zero.", + "error validating max-memory: number must be greater or equal to zero", clusterID): {"--min-memory", "1", "--max-memory", "-1"}, fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s': "+ - "Error validating memory range: max value must be greater or equal than min value 10.", + "error validating memory range: max value must be greater or equal than min value 10.", clusterID): {"--min-memory", "10", "--max-memory", "8"}, "Error: invalid argument \"ty\" for \"--scale-down-enabled\" flag: " + "strconv.ParseBool: parsing \"ty\": " + "invalid syntax": {"--scale-down-enabled=ty"}, fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s': "+ - "Error validating delay-after-add: time: "+ + "error validating delay-after-add: time: "+ "unknown unit \"-\" in duration \"20-\"", clusterID): {"--scale-down-delay-after-add", "20-"}, "Error: invalid argument \"ss\" for \"--scale-down-utilization-threshold\" " + "flag: strconv.ParseFloat: parsing \"ss\": " + "invalid syntax": {"--scale-down-utilization-threshold", "ss"}, fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s': "+ - "Error validating utilization-threshold: "+ - "Expecting a floating-point number between 0 and 1.", + "error validating utilization-threshold: "+ + "expecting a floating-point number greater than 0 and less than 1", clusterID): {"--scale-down-utilization-threshold", "-1"}, fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s': "+ - "Error validating utilization-threshold: "+ - "Expecting a floating-point number between 0 and 1.", + "error validating utilization-threshold: "+ + "expecting a floating-point number greater than 0 and less than 1", clusterID): {"--scale-down-utilization-threshold", "2"}, fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s': "+ - "Error validating delay-after-delete: time: "+ + "error validating delay-after-delete: time: "+ "unknown unit \"-\" in duration \"20-\"", clusterID): {"--scale-down-delay-after-delete", "20-"}, fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s': "+ - "Error validating delay-after-failure: time: "+ + "error validating delay-after-failure: time: "+ "unknown unit \"-\" in duration \"20-\"", clusterID): {"--scale-down-delay-after-failure", "20-"}, fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s': "+ - "Error validating unneeded-time: time: "+ + "error validating unneeded-time: time: "+ "unknown unit \"-\" in duration \"20-\"", clusterID): {"--scale-down-unneeded-time", "20-"}, fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s': "+ - "Error validating GPU range: "+ - "max value must be greater or equal than min value 10.", + "error validating GPU range: "+ + "max value must be greater or equal than min value 10", clusterID): {"--gpu-limit", "nvidia.com/gpu,10,0"}, fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s': "+ - "Error validating GPU range: "+ - "max value must be greater or equal than min value 5.", + "error validating GPU range: "+ + "max value must be greater or equal than min value 5", clusterID): {"--gpu-limit", "amd.com/gpu,5,1"}, "Error: invalid argument \"100000000000000000000000\" for " + "\"--max-cores\" flag: " + @@ -765,7 +765,7 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { "--min-memory", "0", "--max-memory", "4096", "--scale-down-enabled", - "--scale-down-utilization-threshold", "1", + "--scale-down-utilization-threshold", "0.5", "--scale-down-delay-after-delete", "10s", "--scale-down-delay-after-failure", "10s", "--gpu-limit", "nvidia.com/gpu,0,10", @@ -802,12 +802,12 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { ": strconv.ParseBool: parsing \"ty\": " + "invalid syntax": {"--skip-nodes-with-local-storage=ty"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s'"+ - ": Error validating log-verbosity: "+ - "Number must be greater or "+ - "equal to zero.", clusterID): {"--log-verbosity", "-1"}, + ": error validating log-verbosity: "+ + "number must be greater or "+ + "equal to zero", clusterID): {"--log-verbosity", "-1"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s'"+ - ": Error validating max-pod-grace-period: "+ - "Number must be greater or equal to zero.", + ": error validating max-pod-grace-period: "+ + "number must be greater or equal to zero", clusterID): {"--max-pod-grace-period", "-1"}, "Error: invalid argument \"ss\" for \"--pod-priority-threshold\" " + "flag: strconv.ParseInt: parsing \"ss\": " + @@ -819,8 +819,8 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { "time: unknown unit \"-\" in duration \"9-\"", clusterID): {"--max-node-provision-time", "9-"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating max-nodes-total: "+ - "Number must be greater or equal to zero", + "error validating max-nodes-total: "+ + "number must be greater or equal to zero", clusterID): {"--max-nodes-total", "-1"}, "Error: if any flags in the group [min-cores max-cores] " + "are set they must all be set; " + @@ -829,13 +829,13 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { "are set they must all be set; " + "missing [min-cores]": {"--max-cores", "1"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating min-cores: Number must be greater or equal to zero.", + "error validating min-cores: number must be greater or equal to zero", clusterID): {"--min-cores", "-1", "--max-cores", "1"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating max-cores: Number must be greater or equal to zero.", + "error validating max-cores: number must be greater or equal to zero", clusterID): {"--min-cores", "1", "--max-cores", "-1"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating cores range: max value must be greater or equal than min value 10.", + "error validating cores range: max value must be greater or equal than min value 10.", clusterID): {"--min-cores", "10", "--max-cores", "8"}, "Error: if any flags in the group [min-memory max-memory] " + "are set they must all be set; " + @@ -844,51 +844,51 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { "are set they must all be set; " + "missing [min-memory]": {"--max-memory", "1"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating min-memory: Number must be greater or equal to zero.", + "error validating min-memory: number must be greater or equal to zero", clusterID): {"--min-memory", "-1", "--max-memory", "1"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating max-memory: Number must be greater or equal to zero.", + "error validating max-memory: number must be greater or equal to zero", clusterID): {"--min-memory", "1", "--max-memory", "-1"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating memory range: max value must be greater or equal than min value 10.", + "error validating memory range: max value must be greater or equal than min value 10.", clusterID): {"--min-memory", "10", "--max-memory", "8"}, "Error: invalid argument \"ty\" for \"--scale-down-enabled\" flag: " + "strconv.ParseBool: parsing \"ty\": " + "invalid syntax": {"--scale-down-enabled=ty"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating delay-after-add: time: "+ + "error validating delay-after-add: time: "+ "unknown unit \"-\" in duration \"20-\"", clusterID): {"--scale-down-delay-after-add", "20-"}, "Error: invalid argument \"ss\" for \"--scale-down-utilization-threshold\" " + "flag: strconv.ParseFloat: parsing \"ss\": " + "invalid syntax": {"--scale-down-utilization-threshold", "ss"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating utilization-threshold: "+ - "Expecting a floating-point number between 0 and 1.", + "error validating utilization-threshold: "+ + "expecting a floating-point number greater than 0 and less than 1", clusterID): {"--scale-down-utilization-threshold", "-1"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating utilization-threshold: "+ - "Expecting a floating-point number between 0 and 1.", + "error validating utilization-threshold: "+ + "expecting a floating-point number greater than 0 and less than 1", clusterID): {"--scale-down-utilization-threshold", "2"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating delay-after-delete: time: "+ + "error validating delay-after-delete: time: "+ "unknown unit \"-\" in duration \"20-\"", clusterID): {"--scale-down-delay-after-delete", "20-"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating delay-after-failure: time: "+ + "error validating delay-after-failure: time: "+ "unknown unit \"-\" in duration \"20-\"", clusterID): {"--scale-down-delay-after-failure", "20-"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating unneeded-time: time: "+ + "error validating unneeded-time: time: "+ "unknown unit \"-\" in duration \"20-\"", clusterID): {"--scale-down-unneeded-time", "20-"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating GPU range: "+ - "max value must be greater or equal than min value 10.", + "error validating GPU range: "+ + "max value must be greater or equal than min value 10", clusterID): {"--gpu-limit", "nvidia.com/gpu,10,0"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating GPU range: "+ - "max value must be greater or equal than min value 5.", + "error validating GPU range: "+ + "max value must be greater or equal than min value 5", clusterID): {"--gpu-limit", "amd.com/gpu,5,1"}, "Error: invalid argument \"100000000000000000000000\" for " + "\"--max-cores\" flag: " + @@ -937,7 +937,7 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { "--min-memory", "0", "--max-memory", "4096", "--scale-down-enabled", - "--scale-down-utilization-threshold", "1", + "--scale-down-utilization-threshold", "0.5", "--scale-down-delay-after-delete", "10s", "--scale-down-delay-after-failure", "10s", "--gpu-limit", "nvidia.com/gpu,0,10", @@ -969,12 +969,12 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { ": strconv.ParseBool: parsing \"ty\": " + "invalid syntax": {"--skip-nodes-with-local-storage=ty"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s'"+ - ": Error validating log-verbosity: "+ - "Number must be greater or "+ - "equal to zero.", clusterID): {"--log-verbosity", "-1"}, + ": error validating log-verbosity: "+ + "number must be greater or "+ + "equal to zero", clusterID): {"--log-verbosity", "-1"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s'"+ - ": Error validating max-pod-grace-period: "+ - "Number must be greater or equal to zero.", + ": error validating max-pod-grace-period: "+ + "number must be greater or equal to zero", clusterID): {"--max-pod-grace-period", "-1"}, "Error: invalid argument \"ss\" for \"--pod-priority-threshold\" " + "flag: strconv.ParseInt: parsing \"ss\": " + @@ -986,8 +986,8 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { "time: unknown unit \"-\" in duration \"9-\"", clusterID): {"--max-node-provision-time", "9-"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating max-nodes-total: "+ - "Number must be greater or equal to zero", + "error validating max-nodes-total: "+ + "number must be greater or equal to zero", clusterID): {"--max-nodes-total", "-1"}, "Error: if any flags in the group [min-cores max-cores] " + "are set they must all be set; " + @@ -996,13 +996,13 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { "are set they must all be set; " + "missing [min-cores]": {"--max-cores", "1"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating min-cores: Number must be greater or equal to zero.", + "error validating min-cores: number must be greater or equal to zero", clusterID): {"--min-cores", "-1", "--max-cores", "1"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating max-cores: Number must be greater or equal to zero.", + "error validating max-cores: number must be greater or equal to zero", clusterID): {"--min-cores", "1", "--max-cores", "-1"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating cores range: max value must be greater or equal than min value 10.", + "error validating cores range: max value must be greater or equal than min value 10.", clusterID): {"--min-cores", "10", "--max-cores", "8"}, "Error: if any flags in the group [min-memory max-memory] " + "are set they must all be set; " + @@ -1011,51 +1011,51 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { "are set they must all be set; " + "missing [min-memory]": {"--max-memory", "1"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating min-memory: Number must be greater or equal to zero.", + "error validating min-memory: number must be greater or equal to zero", clusterID): {"--min-memory", "-1", "--max-memory", "1"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating max-memory: Number must be greater or equal to zero.", + "error validating max-memory: number must be greater or equal to zero", clusterID): {"--min-memory", "1", "--max-memory", "-1"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating memory range: max value must be greater or equal than min value 10.", + "error validating memory range: max value must be greater or equal than min value 10.", clusterID): {"--min-memory", "10", "--max-memory", "8"}, "Error: invalid argument \"ty\" for \"--scale-down-enabled\" flag: " + "strconv.ParseBool: parsing \"ty\": " + "invalid syntax": {"--scale-down-enabled=ty"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating delay-after-add: time: "+ + "error validating delay-after-add: time: "+ "unknown unit \"-\" in duration \"20-\"", clusterID): {"--scale-down-delay-after-add", "20-"}, "Error: invalid argument \"ss\" for \"--scale-down-utilization-threshold\" " + "flag: strconv.ParseFloat: parsing \"ss\": " + "invalid syntax": {"--scale-down-utilization-threshold", "ss"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating utilization-threshold: "+ - "Expecting a floating-point number between 0 and 1.", + "error validating utilization-threshold: "+ + "expecting a floating-point number greater than 0 and less than 1", clusterID): {"--scale-down-utilization-threshold", "-1"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating utilization-threshold: "+ - "Expecting a floating-point number between 0 and 1.", + "error validating utilization-threshold: "+ + "expecting a floating-point number greater than 0 and less than 1", clusterID): {"--scale-down-utilization-threshold", "2"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating delay-after-delete: time: "+ + "error validating delay-after-delete: time: "+ "unknown unit \"-\" in duration \"20-\"", clusterID): {"--scale-down-delay-after-delete", "20-"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating delay-after-failure: time: "+ + "error validating delay-after-failure: time: "+ "unknown unit \"-\" in duration \"20-\"", clusterID): {"--scale-down-delay-after-failure", "20-"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating unneeded-time: time: "+ + "error validating unneeded-time: time: "+ "unknown unit \"-\" in duration \"20-\"", clusterID): {"--scale-down-unneeded-time", "20-"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating GPU range: "+ - "max value must be greater or equal than min value 10.", + "error validating GPU range: "+ + "max value must be greater or equal than min value 10", clusterID): {"--gpu-limit", "nvidia.com/gpu,10,0"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "Error validating GPU range: "+ - "max value must be greater or equal than min value 5.", + "error validating GPU range: "+ + "max value must be greater or equal than min value 5", clusterID): {"--gpu-limit", "amd.com/gpu,5,1"}, "Error: invalid argument \"100000000000000000000000\" for " + "\"--max-cores\" flag: " + diff --git a/tests/e2e/test_rosacli_cluster.go b/tests/e2e/test_rosacli_cluster.go index 6b34414b63..9e36979b9e 100644 --- a/tests/e2e/test_rosacli_cluster.go +++ b/tests/e2e/test_rosacli_cluster.go @@ -2565,53 +2565,53 @@ var _ = Describe("Classic cluster creation negative testing", basicFlags := []string{"--enable-autoscaling", "--min-replicas", "3", "--max-replicas", "3"} errAndFlagMap := map[string][]string{ - "Error validating log-verbosity: " + - "Number must be greater or equal " + + "error validating log-verbosity: " + + "number must be greater or equal" + "to zero": {"--autoscaler-log-verbosity", "-2"}, - "Error validating utilization-threshold: Expecting" + - " a floating-point number between " + - "0 and 1": {"--autoscaler-scale-down-utilization-threshold", "1.3"}, + "error validating utilization-threshold: expecting" + + " a floating-point number greater than 0 and less" + + " than 1": {"--autoscaler-scale-down-utilization-threshold", "1.3"}, - "Error validating delay-after-add: " + + "error validating delay-after-add: " + "time: invalid duration \"e\"": {"--autoscaler-scale-down-delay-after-add", "e"}, - "Error validating delay-after-delete: " + + "error validating delay-after-delete: " + "time: missing unit in duration \"3.3\"": { "--autoscaler-scale-down-delay-after-delete", "3.3", }, - "Error validating min-cores: Number " + + "error validating min-cores: number " + "must be greater or equal to zero": { "--autoscaler-min-cores", "-5", "--autoscaler-max-cores", "0", }, - "Error validating max-cores: Number" + + "error validating max-cores: number" + " must be greater or equal to zero": { "--autoscaler-min-cores", "0", "--autoscaler-max-cores", "-5", }, - "Error validating cores range: max" + + "error validating cores range: max" + " value must be greater or equal than min value 100": { "--autoscaler-min-cores", "100", "--autoscaler-max-cores", "5", }, - "Error validating max-cores: Should" + + "error validating max-cores: should" + " provide an integer number between 0 to 2147483647": { "--autoscaler-min-cores", "5", "--autoscaler-max-cores", "1152000000000", }, - "Error validating memory range: max value" + + "error validating memory range: max value" + " must be greater or equal than min value 1000": { "--autoscaler-min-memory", "1000", "--autoscaler-max-memory", "100", }, - "Error validating GPU range: max value " + + "error validating GPU range: max value " + "must be greater or equal than min value 15": { "--autoscaler-gpu-limit", "nvidia.com/gpu,0,10", "--autoscaler-gpu-limit", "amd.com/gpu,15,5", From b7e08c75057651c719100b86232382203841c857 Mon Sep 17 00:00:00 2001 From: Matt Clark Date: Thu, 10 Sep 2026 08:01:49 -0700 Subject: [PATCH 2/4] ROSAENG-62105 | test: include actual value in PercentageValidator error and add comprehensive boundary tests - Update PercentageValidator error message to include the actual invalid value - This makes errors more user-friendly and allows testing all boundary cases - Add e2e tests for all invalid threshold values: -1, 0, 1, and 2 - Previously, duplicate error messages prevented testing multiple invalid values - Addresses reviewer feedback from PR #3398 --- pkg/ocm/validators.go | 2 +- tests/e2e/rosa_autoscaler_test.go | 24 ++++++++++++++++++++---- tests/e2e/test_rosacli_cluster.go | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/pkg/ocm/validators.go b/pkg/ocm/validators.go index 9cf28afaba..290ddb8899 100644 --- a/pkg/ocm/validators.go +++ b/pkg/ocm/validators.go @@ -70,7 +70,7 @@ func PercentageValidator(val interface{}) error { } if number >= 1 || number <= 0 || math.IsNaN(number) { - return fmt.Errorf("expecting a floating-point number greater than 0 and less than 1") + return fmt.Errorf("expecting a floating-point number greater than 0 and less than 1, got %v", number) } return nil diff --git a/tests/e2e/rosa_autoscaler_test.go b/tests/e2e/rosa_autoscaler_test.go index 7e949ef552..75d5381cca 100644 --- a/tests/e2e/rosa_autoscaler_test.go +++ b/tests/e2e/rosa_autoscaler_test.go @@ -705,11 +705,19 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { "invalid syntax": {"--scale-down-utilization-threshold", "ss"}, fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s': "+ "error validating utilization-threshold: "+ - "expecting a floating-point number greater than 0 and less than 1", + "expecting a floating-point number greater than 0 and less than 1, got -1", clusterID): {"--scale-down-utilization-threshold", "-1"}, fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s': "+ "error validating utilization-threshold: "+ - "expecting a floating-point number greater than 0 and less than 1", + "expecting a floating-point number greater than 0 and less than 1, got 0", + clusterID): {"--scale-down-utilization-threshold", "0"}, + fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s': "+ + "error validating utilization-threshold: "+ + "expecting a floating-point number greater than 0 and less than 1, got 1", + clusterID): {"--scale-down-utilization-threshold", "1"}, + fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s': "+ + "error validating utilization-threshold: "+ + "expecting a floating-point number greater than 0 and less than 1, got 2", clusterID): {"--scale-down-utilization-threshold", "2"}, fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s': "+ "error validating delay-after-delete: time: "+ @@ -864,11 +872,19 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { "invalid syntax": {"--scale-down-utilization-threshold", "ss"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ "error validating utilization-threshold: "+ - "expecting a floating-point number greater than 0 and less than 1", + "expecting a floating-point number greater than 0 and less than 1, got -1", clusterID): {"--scale-down-utilization-threshold", "-1"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ "error validating utilization-threshold: "+ - "expecting a floating-point number greater than 0 and less than 1", + "expecting a floating-point number greater than 0 and less than 1, got 0", + clusterID): {"--scale-down-utilization-threshold", "0"}, + fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ + "error validating utilization-threshold: "+ + "expecting a floating-point number greater than 0 and less than 1, got 1", + clusterID): {"--scale-down-utilization-threshold", "1"}, + fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ + "error validating utilization-threshold: "+ + "expecting a floating-point number greater than 0 and less than 1, got 2", clusterID): {"--scale-down-utilization-threshold", "2"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ "error validating delay-after-delete: time: "+ diff --git a/tests/e2e/test_rosacli_cluster.go b/tests/e2e/test_rosacli_cluster.go index 9e36979b9e..778cd8234b 100644 --- a/tests/e2e/test_rosacli_cluster.go +++ b/tests/e2e/test_rosacli_cluster.go @@ -2571,7 +2571,7 @@ var _ = Describe("Classic cluster creation negative testing", "error validating utilization-threshold: expecting" + " a floating-point number greater than 0 and less" + - " than 1": {"--autoscaler-scale-down-utilization-threshold", "1.3"}, + " than 1, got 1.3": {"--autoscaler-scale-down-utilization-threshold", "1.3"}, "error validating delay-after-add: " + "time: invalid duration \"e\"": {"--autoscaler-scale-down-delay-after-add", "e"}, From 16e9942ddf6eebbd78530e414d367a2b3948b36d Mon Sep 17 00:00:00 2001 From: Matt Clark Date: Thu, 10 Sep 2026 09:07:58 -0700 Subject: [PATCH 3/4] ROSAENG-62105 | chore: add depguard nolint annotations for architectural boundary violations - Add nolint:depguard annotations to pkg/clusterautoscaler/flags.go - Required after touching file per ROSAENG-62490 architectural linting rules - File imports cobra/pflag/interactive which violate core layer boundaries - Annotations allow lint to pass until file can be properly refactored --- pkg/clusterautoscaler/flags.go | 6 +++--- tests/e2e/test_rosacli_cluster.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/clusterautoscaler/flags.go b/pkg/clusterautoscaler/flags.go index f85fc16d86..f41b1cf866 100644 --- a/pkg/clusterautoscaler/flags.go +++ b/pkg/clusterautoscaler/flags.go @@ -7,11 +7,11 @@ import ( commonUtils "github.com/openshift-online/ocm-common/pkg/utils" cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1" - "github.com/spf13/cobra" - "github.com/spf13/pflag" + "github.com/spf13/cobra" //nolint:depguard + "github.com/spf13/pflag" //nolint:depguard "github.com/openshift/rosa/pkg/helper/versions" - "github.com/openshift/rosa/pkg/interactive" + "github.com/openshift/rosa/pkg/interactive" //nolint:depguard "github.com/openshift/rosa/pkg/ocm" ) diff --git a/tests/e2e/test_rosacli_cluster.go b/tests/e2e/test_rosacli_cluster.go index 778cd8234b..992a96785b 100644 --- a/tests/e2e/test_rosacli_cluster.go +++ b/tests/e2e/test_rosacli_cluster.go @@ -2566,7 +2566,7 @@ var _ = Describe("Classic cluster creation negative testing", errAndFlagMap := map[string][]string{ "error validating log-verbosity: " + - "number must be greater or equal" + + "number must be greater or equal " + "to zero": {"--autoscaler-log-verbosity", "-2"}, "error validating utilization-threshold: expecting" + From 9d07cd027fd303aec7cbccce64946d6581c703ee Mon Sep 17 00:00:00 2001 From: Matt Clark Date: Mon, 14 Sep 2026 16:56:43 -0700 Subject: [PATCH 4/4] ROSAENG-62105 | test: fix e2e autoscaler validation expectations - Remove trailing periods from cores-range and memory-range error messages - Add boundary test cases (0, 1) to edit-HCP validation tests - Fix duplicate map keys in edit-HCP by including actual values in error messages - Align edit-HCP validation tests with create-classic and edit-classic formats Addresses feedback from @olucasfreitas: - Line 679, 694 (create-classic): Remove trailing period - Line 846, 861 (edit-classic): Remove trailing period - Line 1021, 1036 (edit-HCP): Remove trailing period - Line 1048-1063 (edit-HCP): Add 'got X' to make unique map keys and add 0/1 boundary cases Co-Authored-By: Claude Sonnet 4.5 --- tests/e2e/rosa_autoscaler_test.go | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/tests/e2e/rosa_autoscaler_test.go b/tests/e2e/rosa_autoscaler_test.go index 75d5381cca..d90ae8f08f 100644 --- a/tests/e2e/rosa_autoscaler_test.go +++ b/tests/e2e/rosa_autoscaler_test.go @@ -676,7 +676,7 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { "error validating max-cores: number must be greater or equal to zero", clusterID): {"--min-cores", "1", "--max-cores", "-1"}, fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s': "+ - "error validating cores range: max value must be greater or equal than min value 10.", + "error validating cores range: max value must be greater or equal than min value 10", clusterID): {"--min-cores", "10", "--max-cores", "8"}, "Error: if any flags in the group [min-memory max-memory] " + "are set they must all be set; " + @@ -691,7 +691,7 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { "error validating max-memory: number must be greater or equal to zero", clusterID): {"--min-memory", "1", "--max-memory", "-1"}, fmt.Sprintf("ERR: Failed creating autoscaler configuration for cluster '%s': "+ - "error validating memory range: max value must be greater or equal than min value 10.", + "error validating memory range: max value must be greater or equal than min value 10", clusterID): {"--min-memory", "10", "--max-memory", "8"}, "Error: invalid argument \"ty\" for \"--scale-down-enabled\" flag: " + "strconv.ParseBool: parsing \"ty\": " + @@ -843,7 +843,7 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { "error validating max-cores: number must be greater or equal to zero", clusterID): {"--min-cores", "1", "--max-cores", "-1"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "error validating cores range: max value must be greater or equal than min value 10.", + "error validating cores range: max value must be greater or equal than min value 10", clusterID): {"--min-cores", "10", "--max-cores", "8"}, "Error: if any flags in the group [min-memory max-memory] " + "are set they must all be set; " + @@ -858,7 +858,7 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { "error validating max-memory: number must be greater or equal to zero", clusterID): {"--min-memory", "1", "--max-memory", "-1"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "error validating memory range: max value must be greater or equal than min value 10.", + "error validating memory range: max value must be greater or equal than min value 10", clusterID): {"--min-memory", "10", "--max-memory", "8"}, "Error: invalid argument \"ty\" for \"--scale-down-enabled\" flag: " + "strconv.ParseBool: parsing \"ty\": " + @@ -1018,7 +1018,7 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { "error validating max-cores: number must be greater or equal to zero", clusterID): {"--min-cores", "1", "--max-cores", "-1"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "error validating cores range: max value must be greater or equal than min value 10.", + "error validating cores range: max value must be greater or equal than min value 10", clusterID): {"--min-cores", "10", "--max-cores", "8"}, "Error: if any flags in the group [min-memory max-memory] " + "are set they must all be set; " + @@ -1033,7 +1033,7 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { "error validating max-memory: number must be greater or equal to zero", clusterID): {"--min-memory", "1", "--max-memory", "-1"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ - "error validating memory range: max value must be greater or equal than min value 10.", + "error validating memory range: max value must be greater or equal than min value 10", clusterID): {"--min-memory", "10", "--max-memory", "8"}, "Error: invalid argument \"ty\" for \"--scale-down-enabled\" flag: " + "strconv.ParseBool: parsing \"ty\": " + @@ -1047,11 +1047,19 @@ var _ = Describe("Autoscaler", labels.Feature.Autoscaler, func() { "invalid syntax": {"--scale-down-utilization-threshold", "ss"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ "error validating utilization-threshold: "+ - "expecting a floating-point number greater than 0 and less than 1", + "expecting a floating-point number greater than 0 and less than 1, got -1", clusterID): {"--scale-down-utilization-threshold", "-1"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ "error validating utilization-threshold: "+ - "expecting a floating-point number greater than 0 and less than 1", + "expecting a floating-point number greater than 0 and less than 1, got 0", + clusterID): {"--scale-down-utilization-threshold", "0"}, + fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ + "error validating utilization-threshold: "+ + "expecting a floating-point number greater than 0 and less than 1, got 1", + clusterID): {"--scale-down-utilization-threshold", "1"}, + fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ + "error validating utilization-threshold: "+ + "expecting a floating-point number greater than 0 and less than 1, got 2", clusterID): {"--scale-down-utilization-threshold", "2"}, fmt.Sprintf("ERR: Failed updating autoscaler configuration for cluster '%s': "+ "error validating delay-after-delete: time: "+