Skip to content

Commit 8892043

Browse files
authored
Merge pull request #1040 from lihonghao314/dev/adapt-spd
feat: adapt to spd updating
2 parents 7c9eb45 + f239e90 commit 8892043

File tree

13 files changed

+38
-50
lines changed

13 files changed

+38
-50
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ require (
1919
github.com/google/uuid v1.3.0
2020
github.com/h2non/gock v1.2.0
2121
github.com/klauspost/cpuid/v2 v2.2.6
22-
github.com/kubewharf/katalyst-api v0.5.8-0.20251209195727-bde2ce2b9b13
22+
github.com/kubewharf/katalyst-api v0.5.8-0.20251212030746-894fa2521a86
2323
github.com/moby/sys/mountinfo v0.6.2
2424
github.com/montanaflynn/stats v0.7.1
2525
github.com/opencontainers/runc v1.1.6

go.sum

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,6 @@ github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7
198198
github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk=
199199
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
200200
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
201-
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
202-
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
203201
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
204202
github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
205203
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
@@ -576,8 +574,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
576574
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
577575
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
578576
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
579-
github.com/kubewharf/katalyst-api v0.5.8-0.20251209195727-bde2ce2b9b13 h1:/R3HuWFoJkynuCnYF7wZ9p9KkzUgYgtDXZlxCeggMgM=
580-
github.com/kubewharf/katalyst-api v0.5.8-0.20251209195727-bde2ce2b9b13/go.mod h1:Y2IeIorxQamF2a3oa0+URztl5QCSty6Jj3zD83R8J9k=
577+
github.com/kubewharf/katalyst-api v0.5.8-0.20251212030746-894fa2521a86 h1:GCqe9PcoTQ7akNDyAmavhnSrPV7sMAoYJ5jKEaJg4Ac=
578+
github.com/kubewharf/katalyst-api v0.5.8-0.20251212030746-894fa2521a86/go.mod h1:Y2IeIorxQamF2a3oa0+URztl5QCSty6Jj3zD83R8J9k=
581579
github.com/kubewharf/kubelet v1.24.6-kubewharf.9 h1:jOTYZt7h/J7I8xQMKMUcJjKf5UFBv37jHWvNp5VRFGc=
582580
github.com/kubewharf/kubelet v1.24.6-kubewharf.9/go.mod h1:MxbSZUx3wXztFneeelwWWlX7NAAStJ6expqq7gY2J3c=
583581
github.com/kyoh86/exportloopref v0.1.7/go.mod h1:h1rDl2Kdj97+Kwh4gdz3ujE7XHmH51Q0lUiZ1z4NLj8=
@@ -605,20 +603,15 @@ github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaO
605603
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
606604
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
607605
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
608-
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
609-
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
610606
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
611607
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
612608
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
613609
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
614610
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
615611
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
616612
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
617-
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
618-
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
619613
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
620614
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
621-
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
622615
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
623616
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
624617
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
@@ -811,11 +804,8 @@ github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6L
811804
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
812805
github.com/rogpeppe/go-internal v1.6.0/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
813806
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
814-
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
815-
github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY=
816807
github.com/rs/zerolog v1.34.0 h1:k43nTLIwcTVQAncfCw4KZ2VY6ukYoZaBPNOE8txlOeY=
817808
github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ=
818-
github.com/rs/zerolog v1.34.0/go.mod h1:bJsvje4Z08ROH4Nhs5iH600c3IkWhwp44iRc54W6wYQ=
819809
github.com/rubiojr/go-vhd v0.0.0-20200706105327-02e210299021/go.mod h1:DM5xW0nvfNNm2uytzsvhI3OnX8uzaRAg8UX/CnDqbto=
820810
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
821811
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
@@ -1286,12 +1276,9 @@ golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBc
12861276
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
12871277
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
12881278
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1289-
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
12901279
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
12911280
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
12921281
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1293-
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
1294-
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
12951282
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
12961283
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
12971284
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=

pkg/controller/ihpa/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func updateStatus(ihpa *v1alpha2.IntelligentHorizontalPodAutoscaler, hpa *v2.Hor
197197
continue
198198
}
199199

200-
var currentMetric *v1beta1.PodMetrics
200+
var currentMetric *apiworkload.PodMetrics
201201
now := time.Now()
202202
for _, item := range aggMetrics.Items {
203203
if now.After(item.Timestamp.Time) {

pkg/controller/ihpa/util_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ func Test_updateStatus(t *testing.T) {
348348
},
349349
{
350350
Scope: resourceportrait.ResourcePortraitPluginName,
351-
Items: []v1beta1.PodMetrics{
351+
Items: []apiworkload.PodMetrics{
352352
{
353353
Timestamp: metav1.Time{Time: time.Now().Add(-time.Minute)},
354354
Containers: []v1beta1.ContainerMetrics{

pkg/controller/spd/indicator-plugin/plugins/resource-portrait/indicator_plugin.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
"k8s.io/client-go/tools/cache"
3636
"k8s.io/client-go/util/workqueue"
3737
"k8s.io/klog/v2"
38-
metrics "k8s.io/metrics/pkg/apis/metrics/v1beta1"
3938

4039
apiconfig "github.com/kubewharf/katalyst-api/pkg/apis/config/v1alpha1"
4140
apiworkload "github.com/kubewharf/katalyst-api/pkg/apis/workload/v1alpha1"
@@ -184,7 +183,7 @@ func (p *ResourcePortraitIndicatorPlugin) emitMetrics() {
184183
continue
185184
}
186185

187-
var currentMetric *metrics.PodMetrics
186+
var currentMetric *apiworkload.PodMetrics
188187
now := time.Now()
189188
for _, item := range aggMetrics.Items {
190189
if now.After(item.Timestamp.Time) {

pkg/controller/spd/indicator-plugin/plugins/resource-portrait/util.go

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
)
3333

3434
// generatePodMetrics will add new portraits based on old portraits and remove expired data.
35-
func generatePodMetrics(algoConf *apiconfig.ResourcePortraitConfig, metrics []apimetrics.PodMetrics, timeSeriesData map[string][]timeSeriesItem, groupData map[string]float64) []apimetrics.PodMetrics {
35+
func generatePodMetrics(algoConf *apiconfig.ResourcePortraitConfig, metrics []apiworkload.PodMetrics, timeSeriesData map[string][]timeSeriesItem, groupData map[string]float64) []apiworkload.PodMetrics {
3636
if algoConf == nil {
3737
return nil
3838
}
@@ -45,20 +45,20 @@ func generatePodMetrics(algoConf *apiconfig.ResourcePortraitConfig, metrics []ap
4545
}
4646

4747
// convertPodMetricsSliceToMap converts slices of metrics into maps, with timestamps as keys.
48-
func convertPodMetricsSliceToMap(metrics []apimetrics.PodMetrics) map[int64]apimetrics.PodMetrics {
49-
return lo.SliceToMap(metrics, func(item apimetrics.PodMetrics) (int64, apimetrics.PodMetrics) {
48+
func convertPodMetricsSliceToMap(metrics []apiworkload.PodMetrics) map[int64]apiworkload.PodMetrics {
49+
return lo.SliceToMap(metrics, func(item apiworkload.PodMetrics) (int64, apiworkload.PodMetrics) {
5050
return item.Timestamp.Time.Unix(), item
5151
})
5252
}
5353

5454
// convertTimeseriesToPodMetricsMap converts time series data into metric maps.
55-
func convertTimeseriesToPodMetricsMap(source, method string, timeSeriesData map[string][]timeSeriesItem, groupData map[string]float64) map[int64]apimetrics.PodMetrics {
55+
func convertTimeseriesToPodMetricsMap(source, method string, timeSeriesData map[string][]timeSeriesItem, groupData map[string]float64) map[int64]apiworkload.PodMetrics {
5656
fakeContainerName := GenerateFakeContainerName(source, method)
57-
podMetricsMap := map[int64]apimetrics.PodMetrics{}
57+
podMetricsMap := map[int64]apiworkload.PodMetrics{}
5858
for resourceName, timeSeries := range timeSeriesData {
5959
for _, item := range timeSeries {
6060
if _, ok := podMetricsMap[item.Timestamp]; !ok {
61-
podMetricsMap[item.Timestamp] = apimetrics.PodMetrics{
61+
podMetricsMap[item.Timestamp] = apiworkload.PodMetrics{
6262
Timestamp: metav1.Time{Time: time.Unix(item.Timestamp, 0)},
6363
Containers: []apimetrics.ContainerMetrics{
6464
{
@@ -78,7 +78,7 @@ func convertTimeseriesToPodMetricsMap(source, method string, timeSeriesData map[
7878
}
7979

8080
// mergePodMetricMap merges two metric maps.
81-
func mergePodMetricMap(a map[int64]apimetrics.PodMetrics, b map[int64]apimetrics.PodMetrics) map[int64]apimetrics.PodMetrics {
81+
func mergePodMetricMap(a map[int64]apiworkload.PodMetrics, b map[int64]apiworkload.PodMetrics) map[int64]apiworkload.PodMetrics {
8282
for k, va := range a {
8383
vb, ok := b[k]
8484
if !ok || len(va.Containers) == 0 || len(vb.Containers) == 0 {
@@ -93,8 +93,8 @@ func mergePodMetricMap(a map[int64]apimetrics.PodMetrics, b map[int64]apimetrics
9393
}
9494

9595
// convertPodMetricsMapToSortedSlice reconverts the metric map into slices and sorts them based on timestamp.
96-
func convertPodMetricsMapToSortedSlice(podMetricsMap map[int64]apimetrics.PodMetrics) []apimetrics.PodMetrics {
97-
podMetrics := lo.MapToSlice(podMetricsMap, func(key int64, value apimetrics.PodMetrics) apimetrics.PodMetrics {
96+
func convertPodMetricsMapToSortedSlice(podMetricsMap map[int64]apiworkload.PodMetrics) []apiworkload.PodMetrics {
97+
podMetrics := lo.MapToSlice(podMetricsMap, func(key int64, value apiworkload.PodMetrics) apiworkload.PodMetrics {
9898
return value
9999
})
100100
sort.Slice(podMetrics, func(i, j int) bool {
@@ -104,9 +104,9 @@ func convertPodMetricsMapToSortedSlice(podMetricsMap map[int64]apimetrics.PodMet
104104
}
105105

106106
// filterExpiredPodMetrics is used to filter out metrics before the current time from the metric slice.
107-
func filterExpiredPodMetrics(metrics []apimetrics.PodMetrics) []apimetrics.PodMetrics {
107+
func filterExpiredPodMetrics(metrics []apiworkload.PodMetrics) []apiworkload.PodMetrics {
108108
now := time.Now()
109-
return lo.Filter(metrics, func(item apimetrics.PodMetrics, _ int) bool {
109+
return lo.Filter(metrics, func(item apiworkload.PodMetrics, _ int) bool {
110110
return now.Before(item.Timestamp.Time)
111111
})
112112
}
@@ -213,7 +213,10 @@ func filterResourcePortraitIndicators(rpIndicator *apiconfig.ResourcePortraitInd
213213
}
214214

215215
func convertAlgorithmResultToAggMetrics(aggMetrics *apiworkload.AggPodMetrics, algoConf *apiconfig.ResourcePortraitConfig, timeseries map[string][]timeSeriesItem, groupData map[string]float64) *apiworkload.AggPodMetrics {
216-
return &apiworkload.AggPodMetrics{Aggregator: apiworkload.Aggregator(algoConf.AlgorithmConfig.TimeWindow.Aggregator), Items: generatePodMetrics(algoConf, aggMetrics.Items, timeseries, groupData)}
216+
return &apiworkload.AggPodMetrics{
217+
Aggregator: apiworkload.Aggregator(algoConf.AlgorithmConfig.TimeWindow.Aggregator),
218+
Items: generatePodMetrics(algoConf, aggMetrics.Items, timeseries, groupData),
219+
}
217220
}
218221

219222
// GenerateFakeContainerName generates fake container name for resource portrait

pkg/controller/spd/indicator-plugin/plugins/resource-portrait/utli_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func TestConvertAlgorithmResultToAggMetrics(t *testing.T) {
234234
timeseries: nil,
235235
groupData: nil,
236236
},
237-
want: &apiworkload.AggPodMetrics{Aggregator: apiworkload.Aggregator("avg"), Items: []v1beta1.PodMetrics{}},
237+
want: &apiworkload.AggPodMetrics{Aggregator: apiworkload.Aggregator("avg"), Items: []apiworkload.PodMetrics{}},
238238
},
239239
}
240240
for _, tt := range tests {
@@ -260,7 +260,7 @@ func TestGeneratePodMetrics(t *testing.T) {
260260
tests := []struct {
261261
name string
262262
args args
263-
want []v1beta1.PodMetrics
263+
want []apiworkload.PodMetrics
264264
}{
265265
{
266266
name: "nil",
@@ -281,13 +281,13 @@ func TestGeneratePodMetrics(t *testing.T) {
281281
timeseries: nil,
282282
groupData: nil,
283283
},
284-
want: []v1beta1.PodMetrics{},
284+
want: []apiworkload.PodMetrics{},
285285
},
286286
{
287287
name: "normal",
288288
args: args{
289289
aggMetrics: &apiworkload.AggPodMetrics{
290-
Items: []v1beta1.PodMetrics{
290+
Items: []apiworkload.PodMetrics{
291291
{
292292
Timestamp: metav1.Time{Time: time.Unix(1, 0)},
293293
Containers: []v1beta1.ContainerMetrics{
@@ -316,7 +316,7 @@ func TestGeneratePodMetrics(t *testing.T) {
316316
},
317317
groupData: map[string]float64{"resourceY": 1},
318318
},
319-
want: []v1beta1.PodMetrics{},
319+
want: []apiworkload.PodMetrics{},
320320
},
321321
}
322322
for _, tt := range tests {
@@ -341,7 +341,7 @@ func TestGenerateMetricsRefreshRecord(t *testing.T) {
341341
args: &apiworkload.AggPodMetrics{
342342
Aggregator: "",
343343
Scope: "",
344-
Items: []v1beta1.PodMetrics{
344+
Items: []apiworkload.PodMetrics{
345345
{
346346
Timestamp: metav1.Time{Time: time.Unix(1, 0)},
347347
Containers: []v1beta1.ContainerMetrics{

pkg/controller/spd/spd_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ func TestIndicatorUpdater(t *testing.T) {
10741074
AggMetrics: []apiworkload.AggPodMetrics{
10751075
{
10761076
Aggregator: apiworkload.Avg,
1077-
Items: []metrics.PodMetrics{
1077+
Items: []apiworkload.PodMetrics{
10781078
{
10791079
Timestamp: metav1.NewTime(time.Date(2022, 1, 1, 1, 0, 0, 0, time.Local)),
10801080
Window: metav1.Duration{Duration: time.Hour},
@@ -1258,7 +1258,7 @@ func TestIndicatorUpdater(t *testing.T) {
12581258
sc.indicatorManager.UpdateAggMetrics(nn, []apiworkload.AggPodMetrics{
12591259
{
12601260
Aggregator: apiworkload.Avg,
1261-
Items: []metrics.PodMetrics{
1261+
Items: []apiworkload.PodMetrics{
12621262
{
12631263
Timestamp: metav1.NewTime(time.Date(2022, 1, 1, 1, 0, 0, 0, time.Local)),
12641264
Window: metav1.Duration{Duration: time.Hour},

pkg/controller/vpa/algorithm/recommenders/avg_load_to_cpu.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
corev1 "k8s.io/api/core/v1"
2424
"k8s.io/apimachinery/pkg/api/resource"
2525
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
26-
metrics "k8s.io/metrics/pkg/apis/metrics/v1beta1"
2726

2827
apis "github.com/kubewharf/katalyst-api/pkg/apis/autoscaling/v1alpha1"
2928
workload "github.com/kubewharf/katalyst-api/pkg/apis/workload/v1alpha1"
@@ -84,7 +83,7 @@ type ContainerStatistic struct {
8483
TimeSum metav1.Duration
8584
}
8685

87-
func (r *SimpleCPURecommender) computeAVGPodMetrics(podMetrics []metrics.PodMetrics, resourceName corev1.ResourceName) map[string]*resource.Quantity {
86+
func (r *SimpleCPURecommender) computeAVGPodMetrics(podMetrics []workload.PodMetrics, resourceName corev1.ResourceName) map[string]*resource.Quantity {
8887
containerResources := make(map[string]*resource.Quantity)
8988
statistics := make(map[string]*ContainerStatistic)
9089

pkg/controller/vpa/algorithm/recommenders/avg_load_to_cpu_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func TestGetRecommendedPodResources(t *testing.T) {
5151
AggMetrics: []workload.AggPodMetrics{
5252
{
5353
Aggregator: "avg",
54-
Items: []metrics.PodMetrics{
54+
Items: []workload.PodMetrics{
5555
{
5656
Timestamp: metav1.NewTime(time.Date(2022, 1, 1, 1, 0, 0, 0, time.UTC)),
5757
Window: metav1.Duration{Duration: time.Hour},
@@ -68,7 +68,7 @@ func TestGetRecommendedPodResources(t *testing.T) {
6868
},
6969
{
7070
Aggregator: "avg",
71-
Items: []metrics.PodMetrics{
71+
Items: []workload.PodMetrics{
7272
{
7373
Timestamp: metav1.NewTime(time.Date(2022, 1, 1, 2, 0, 0, 0, time.UTC)),
7474
Window: metav1.Duration{Duration: time.Hour},

0 commit comments

Comments
 (0)