Skip to content
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

Drop support to ValueMetricType using cpu_memory_scaler #2218

Merged
merged 4 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
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