From 312a97db762ef9a26c413dbebe53c9e170ca1b7e Mon Sep 17 00:00:00 2001 From: jorturfer Date: Tue, 26 Oct 2021 21:04:08 +0200 Subject: [PATCH 1/4] Delete ValueMetricType from cpu_memory_scaler Signed-off-by: jorturfer --- pkg/scalers/cpu_memory_scaler.go | 5 ----- pkg/scalers/cpu_memory_scaler_test.go | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/pkg/scalers/cpu_memory_scaler.go b/pkg/scalers/cpu_memory_scaler.go index 813cfe3d22b..793488ac324 100644 --- a/pkg/scalers/cpu_memory_scaler.go +++ b/pkg/scalers/cpu_memory_scaler.go @@ -19,7 +19,6 @@ type cpuMemoryScaler struct { type cpuMemoryMetadata struct { Type v2beta2.MetricTargetType - Value *resource.Quantity AverageValue *resource.Quantity AverageUtilization *int32 } @@ -51,9 +50,6 @@ func parseResourceMetadata(config *ScalerConfig) (*cpuMemoryMetadata, error) { return nil, fmt.Errorf("no value given") } switch meta.Type { - case v2beta2.ValueMetricType: - valueQuantity := resource.MustParse(value) - meta.Value = &valueQuantity case v2beta2.AverageValueMetricType: averageValueQuantity := resource.MustParse(value) meta.AverageValue = &averageValueQuantity @@ -86,7 +82,6 @@ func (s *cpuMemoryScaler) GetMetricSpecForScaling(context.Context) []v2beta2.Met Name: s.resourceName, Target: v2beta2.MetricTarget{ Type: s.metadata.Type, - Value: s.metadata.Value, AverageUtilization: s.metadata.AverageUtilization, AverageValue: s.metadata.AverageValue, }, diff --git a/pkg/scalers/cpu_memory_scaler_test.go b/pkg/scalers/cpu_memory_scaler_test.go index 9866b8b21d4..6d599475992 100644 --- a/pkg/scalers/cpu_memory_scaler_test.go +++ b/pkg/scalers/cpu_memory_scaler_test.go @@ -23,9 +23,9 @@ var validCPUMemoryMetadata = map[string]string{ var testCPUMemoryMetadata = []parseCPUMemoryMetadataTestData{ {map[string]string{}, true}, {validCPUMemoryMetadata, false}, - {map[string]string{"type": "Utilization", "value": "50"}, false}, - {map[string]string{"type": "Value", "value": "50"}, false}, + {map[string]string{"type": "Utilization", "value": "50"}, false}, {map[string]string{"type": "AverageValue", "value": "50"}, false}, + {map[string]string{"type": "Value", "value": "50"}, true}, {map[string]string{"type": "AverageValue"}, true}, {map[string]string{"type": "xxx", "value": "50"}, true}, } From 291fde9bf17cd0d96f6f80ba42ff530b3cced985 Mon Sep 17 00:00:00 2001 From: jorturfer Date: Tue, 26 Oct 2021 19:38:40 +0000 Subject: [PATCH 2/4] Update changelog Signed-off-by: jorturfer --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a1054b799b..38a901c0db4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -61,6 +61,7 @@ - Add Makefile mockgen targets ([#2090](https://github.com/kedacore/keda/issues/2090)) - Prometheus scaler: omit `serverAddress` from generated metric name ([#2099](https://github.com/kedacore/keda/pull/2099)) - Add Makefile mockgen targets ([#2090](https://github.com/kedacore/keda/issues/2090)|[#2184](https://github.com/kedacore/keda/pull/2184)) +- Drop support to `ValueMetricType` using cpu_memory_scaler ([#2218](https://github.com/kedacore/keda/issues/2218)) ## v2.4.0 From 019b3a39542f1563e3436f21a09d36a1ed27f96a Mon Sep 17 00:00:00 2001 From: jorturfer Date: Tue, 26 Oct 2021 21:51:01 +0200 Subject: [PATCH 3/4] Remove whitespace Signed-off-by: jorturfer --- pkg/scalers/cpu_memory_scaler_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/scalers/cpu_memory_scaler_test.go b/pkg/scalers/cpu_memory_scaler_test.go index 6d599475992..18a6a491449 100644 --- a/pkg/scalers/cpu_memory_scaler_test.go +++ b/pkg/scalers/cpu_memory_scaler_test.go @@ -23,7 +23,7 @@ var validCPUMemoryMetadata = map[string]string{ var testCPUMemoryMetadata = []parseCPUMemoryMetadataTestData{ {map[string]string{}, true}, {validCPUMemoryMetadata, false}, - {map[string]string{"type": "Utilization", "value": "50"}, false}, + {map[string]string{"type": "Utilization", "value": "50"}, false}, {map[string]string{"type": "AverageValue", "value": "50"}, false}, {map[string]string{"type": "Value", "value": "50"}, true}, {map[string]string{"type": "AverageValue"}, true}, From ef15fdab815dec520afd30db95ca11174b6fff9a Mon Sep 17 00:00:00 2001 From: Jorge Turrado Date: Wed, 27 Oct 2021 08:59:59 +0200 Subject: [PATCH 4/4] Add more explicit error message Signed-off-by: Jorge Turrado --- pkg/scalers/cpu_memory_scaler.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/scalers/cpu_memory_scaler.go b/pkg/scalers/cpu_memory_scaler.go index 793488ac324..4e6283779bb 100644 --- a/pkg/scalers/cpu_memory_scaler.go +++ b/pkg/scalers/cpu_memory_scaler.go @@ -61,7 +61,7 @@ func parseResourceMetadata(config *ScalerConfig) (*cpuMemoryMetadata, error) { utilizationNum := int32(valueNum) meta.AverageUtilization = &utilizationNum default: - return nil, fmt.Errorf("unsupport type") + return nil, fmt.Errorf("unsupported metric type, allowed values are 'Utilization' or 'AverageValue'") } return meta, nil }