Skip to content

Commit

Permalink
Drop support to ValueMetricType using cpu_memory_scaler (#2218)
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Turrado <[email protected]>
  • Loading branch information
Jorge Turrado Ferrero authored Oct 27, 2021
1 parent d1bed54 commit 49d60dc
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 1 addition & 6 deletions pkg/scalers/cpu_memory_scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ type cpuMemoryScaler struct {

type cpuMemoryMetadata struct {
Type v2beta2.MetricTargetType
Value *resource.Quantity
AverageValue *resource.Quantity
AverageUtilization *int32
}
Expand Down Expand Up @@ -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
Expand All @@ -65,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
}
Expand All @@ -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,
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/scalers/cpu_memory_scaler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ 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": "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},
}
Expand Down

0 comments on commit 49d60dc

Please sign in to comment.