Skip to content

Commit d045cc8

Browse files
committed
minor refactor: functions naming combined groups
1 parent 5b51e32 commit d045cc8

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

pkg/agent/qrm-plugins/mb/advisor/advisor_decorator.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ package advisor
1818

1919
import (
2020
"context"
21-
"strings"
22-
2321
"k8s.io/apimachinery/pkg/util/sets"
2422

2523
"github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/mb/monitor"
@@ -87,7 +85,7 @@ func (d *priorityGroupDecorator) combinedDomainStats(domainsMon *monitor.DomainS
8785

8886
func (d *priorityGroupDecorator) splitPlan(mbPlan *plan.MBPlan, groupInfos *groupInfo) *plan.MBPlan {
8987
for groupKey, ccdPlan := range mbPlan.MBGroups {
90-
if !strings.Contains(groupKey, "combined-") {
88+
if !isCombinedGroup(groupKey) {
9189
continue
9290
}
9391
for _, domainGroupInfos := range groupInfos.DomainGroups {

pkg/agent/qrm-plugins/mb/advisor/advisor_helper.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import (
3030
"github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/mb/plan"
3131
)
3232

33+
const combinedGroupPrefix = "combined-"
34+
3335
// getMinEffectiveCapacity identifies the min dynamic capacity required by pre-defined groups,
3436
// if the specific groups have active MB traffics
3537
func getMinEffectiveCapacity(base int, groupCaps map[string]int, incomingStats monitor.GroupMBStats) int {
@@ -206,8 +208,11 @@ func preProcessGroupSumStat(sumStats map[string][]monitor.MBInfo) map[string][]m
206208
continue
207209
}
208210

209-
newKey := fmt.Sprintf("combined-%d", weight)
210-
sumList := make([]monitor.MBInfo, len(sumStats[equivGroups[0]]))
211+
newKey := getCombinedGroupKey(weight)
212+
// sumStats holds outgoing summary of each domain for each group, in other words,
213+
// each slot of sumStats has uniform shape: slice with length of domain number
214+
numDomains := len(sumStats[equivGroups[0]])
215+
sumList := make([]monitor.MBInfo, numDomains)
211216

212217
for _, group := range equivGroups {
213218
for id, stat := range sumStats[group] {
@@ -222,6 +227,15 @@ func preProcessGroupSumStat(sumStats map[string][]monitor.MBInfo) map[string][]m
222227
return result
223228
}
224229

230+
func getCombinedGroupKey(weight int) string {
231+
newKey := fmt.Sprintf("%s%d", combinedGroupPrefix, weight)
232+
return newKey
233+
}
234+
235+
func isCombinedGroup(groupName string) bool {
236+
return strings.Contains(groupName, combinedGroupPrefix)
237+
}
238+
225239
func getLimitsByGroupSorted(capacity int, groupSorting []sets.String, groupUsages map[string]int) (int, map[string]int) {
226240
result := make(map[string]int)
227241

0 commit comments

Comments
 (0)