Skip to content

Commit

Permalink
not predict for memory in ehpa
Browse files Browse the repository at this point in the history
  • Loading branch information
qmhu committed Feb 23, 2022
1 parent 24e4783 commit ca5b183
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 13 deletions.
4 changes: 1 addition & 3 deletions pkg/controller/ehpa/hpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func (c *EffectiveHPAController) GetHPAMetrics(ctx context.Context, ehpa *autosc
if metric.Type == autoscalingv2.ResourceMetricSourceType {
name, err := GetPredictionMetricName(metric.Resource.Name)
if err != nil {
return nil, err
continue
}

customMetric := &autoscalingv2.PodsMetricSource{
Expand Down Expand Up @@ -251,8 +251,6 @@ func GetPredictionMetricName(Name v1.ResourceName) (string, error) {
switch Name {
case v1.ResourceCPU:
return known.MetricNamePodCpuUsage, nil
case v1.ResourceMemory:
return known.MetricNamePodMemoryUsage, nil
default:
return "", fmt.Errorf("resource name not predictable")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/ehpa/predict.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (c *EffectiveHPAController) NewPredictionObject(ehpa *autoscalingapi.Effect
if metric.Type == autoscalingv2.ResourceMetricSourceType {
metricName, err := GetPredictionMetricName(metric.Resource.Name)
if err != nil {
return nil, err
continue
}

predictionMetrics = append(predictionMetrics, predictionapi.PredictionMetric{
Expand Down
3 changes: 1 addition & 2 deletions pkg/known/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ const (
)

const (
MetricNamePodCpuUsage = "pod_cpu_usage"
MetricNamePodMemoryUsage = "pod_memory_usage"
MetricNamePodCpuUsage = "crane_pod_cpu_usage"
)
7 changes: 0 additions & 7 deletions pkg/metricprovider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ func (p *MetricProvider) GetMetricBySelector(ctx context.Context, namespace stri

if info.Metric == known.MetricNamePodCpuUsage {
metric.Value = *resource.NewMilliQuantity(averageValue, resource.DecimalSI)
} else if info.Metric == known.MetricNamePodMemoryUsage {
metric.Value = *resource.NewMilliQuantity(averageValue, resource.BinarySI)
}

matchingMetrics = append(matchingMetrics, metric)
Expand Down Expand Up @@ -189,11 +187,6 @@ func ListAllLocalMetrics() []provider.CustomMetricInfo {
Namespaced: true,
Metric: known.MetricNamePodCpuUsage,
},
{
GroupResource: schema.GroupResource{Group: "", Resource: "pods"},
Namespaced: true,
Metric: known.MetricNamePodMemoryUsage,
},
}
}

Expand Down

0 comments on commit ca5b183

Please sign in to comment.