Skip to content

Commit 356adb7

Browse files
authored
Merge pull request #747 from gary-lgy/qrm-sync
feat(qrm-plugins): synchronous GetAdvice API between qrm-plugins and sys-advisor
2 parents b1b3500 + 8777736 commit 356adb7

File tree

36 files changed

+5036
-907
lines changed

36 files changed

+5036
-907
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,12 @@ generate-sys-advisor-cpu-plugin:
7777
AdvisorSvcPath = $(MakeFilePath)/pkg/agent/qrm-plugins/advisorsvc/
7878
.PHONY: generate-advisor-svc ## Generate protocol for general qrm-plugin with sys-advisor
7979
generate-advisor-svc:
80+
mkdir -p $(TempRepoDir)/github.com/kubewharf && \
81+
mkdir -p $(TempRepoDir)/github.com/gogo && \
82+
git clone https://github.com/kubewharf/kubelet.git $(TempRepoDir)/github.com/kubewharf/kubelet && \
83+
git clone https://github.com/gogo/protobuf.git $(TempRepoDir)/github.com/gogo/protobuf && \
8084
targetTag=`cat $(MakeFilePath)/go.mod | grep kubewharf/kubelet | awk '{print $$4}'` && \
81-
cd $(GOPATH)/src/github.com/kubewharf/kubelet && \
85+
cd $(TempRepoDir)/github.com/kubewharf/kubelet && \
8286
git fetch --tags && \
8387
git checkout $$targetTag && \
8488
cd - && \

cmd/katalyst-agent/app/options/qrm/cpu_plugin.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ limitations under the License.
1717
package qrm
1818

1919
import (
20+
"time"
21+
2022
cliflag "k8s.io/component-base/cli/flag"
2123

2224
"github.com/kubewharf/katalyst-core/pkg/agent/qrm-plugins/commonstate"
@@ -35,6 +37,7 @@ type CPUOptions struct {
3537

3638
type CPUDynamicPolicyOptions struct {
3739
EnableCPUAdvisor bool
40+
AdvisorGetAdviceInterval time.Duration
3841
EnableCPUPressureEviction bool
3942
LoadPressureEvictionSkipPools []string
4043
EnableSyncingCPUIdle bool
@@ -55,6 +58,7 @@ func NewCPUOptions() *CPUOptions {
5558
SkipCPUStateCorruption: false,
5659
CPUDynamicPolicyOptions: CPUDynamicPolicyOptions{
5760
EnableCPUAdvisor: false,
61+
AdvisorGetAdviceInterval: 5 * time.Second,
5862
EnableCPUPressureEviction: false,
5963
EnableSyncingCPUIdle: false,
6064
EnableCPUIdle: false,
@@ -80,6 +84,8 @@ func (o *CPUOptions) AddFlags(fss *cliflag.NamedFlagSets) {
8084
o.PolicyName, "The policy cpu resource plugin should use")
8185
fs.BoolVar(&o.EnableCPUAdvisor, "cpu-resource-plugin-advisor",
8286
o.EnableCPUAdvisor, "Whether cpu resource plugin should enable sys-advisor")
87+
fs.DurationVar(&o.AdvisorGetAdviceInterval, "cpu-resource-plugin-advisor-interval",
88+
o.AdvisorGetAdviceInterval, "If cpu advisor is enabled, this is the interval at which we get advice from sys-advisor")
8389
fs.IntVar(&o.ReservedCPUCores, "cpu-resource-plugin-reserved",
8490
o.ReservedCPUCores, "The total cores cpu resource plugin should reserve")
8591
fs.BoolVar(&o.SkipCPUStateCorruption, "skip-cpu-state-corruption",
@@ -108,6 +114,7 @@ func (o *CPUOptions) AddFlags(fss *cliflag.NamedFlagSets) {
108114
func (o *CPUOptions) ApplyTo(conf *qrmconfig.CPUQRMPluginConfig) error {
109115
conf.PolicyName = o.PolicyName
110116
conf.EnableCPUAdvisor = o.EnableCPUAdvisor
117+
conf.GetAdviceInterval = o.AdvisorGetAdviceInterval
111118
conf.ReservedCPUCores = o.ReservedCPUCores
112119
conf.SkipCPUStateCorruption = o.SkipCPUStateCorruption
113120
conf.EnableCPUPressureEviction = o.EnableCPUPressureEviction

cmd/katalyst-agent/app/options/qrm/memory_plugin.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type MemoryOptions struct {
3131
SkipMemoryStateCorruption bool
3232
EnableSettingMemoryMigrate bool
3333
EnableMemoryAdvisor bool
34+
AdvisorGetAdviceInterval time.Duration
3435
ExtraControlKnobConfigFile string
3536
EnableOOMPriority bool
3637
OOMPriorityPinnedMapAbsPath string
@@ -77,12 +78,13 @@ type FragMemOptions struct {
7778

7879
func NewMemoryOptions() *MemoryOptions {
7980
return &MemoryOptions{
80-
PolicyName: "dynamic",
81-
ReservedMemoryGB: 0,
82-
SkipMemoryStateCorruption: false,
83-
EnableSettingMemoryMigrate: false,
84-
EnableMemoryAdvisor: false,
85-
EnableOOMPriority: false,
81+
PolicyName: "dynamic",
82+
ReservedMemoryGB: 0,
83+
SkipMemoryStateCorruption: false,
84+
EnableSettingMemoryMigrate: false,
85+
EnableMemoryAdvisor: false,
86+
AdvisorGetAdviceInterval: 5 * time.Second,
87+
EnableOOMPriority: false,
8688
EnableNonBindingShareCoresMemoryResourceCheck: true,
8789
EnableNUMAAllocationReactor: false,
8890
NUMABindResultResourceAllocationAnnotationKey: consts.QRMResourceAnnotationKeyNUMABindResult,
@@ -120,6 +122,8 @@ func (o *MemoryOptions) AddFlags(fss *cliflag.NamedFlagSets) {
120122
o.EnableSettingMemoryMigrate, "if set true, we will enable cpuset.memory_migrate for containers not numa_binding")
121123
fs.BoolVar(&o.EnableMemoryAdvisor, "memory-resource-plugin-advisor",
122124
o.EnableMemoryAdvisor, "Whether memory resource plugin should enable sys-advisor")
125+
fs.DurationVar(&o.AdvisorGetAdviceInterval, "memory-resource-plugin-advisor-interval",
126+
o.AdvisorGetAdviceInterval, "If memory advisor is enabled, this is the interval at which we get advice from sys-advisor")
123127
fs.StringVar(&o.ExtraControlKnobConfigFile, "memory-extra-control-knob-config-file",
124128
o.ExtraControlKnobConfigFile, "the absolute path of extra control knob config file")
125129
fs.BoolVar(&o.EnableOOMPriority, "enable-oom-priority",
@@ -164,6 +168,7 @@ func (o *MemoryOptions) ApplyTo(conf *qrmconfig.MemoryQRMPluginConfig) error {
164168
conf.SkipMemoryStateCorruption = o.SkipMemoryStateCorruption
165169
conf.EnableSettingMemoryMigrate = o.EnableSettingMemoryMigrate
166170
conf.EnableMemoryAdvisor = o.EnableMemoryAdvisor
171+
conf.GetAdviceInterval = o.AdvisorGetAdviceInterval
167172
conf.ExtraControlKnobConfigFile = o.ExtraControlKnobConfigFile
168173
conf.EnableOOMPriority = o.EnableOOMPriority
169174
conf.EnableNonBindingShareCoresMemoryResourceCheck = o.EnableNonBindingShareCoresMemoryResourceCheck

codecov.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ coverage:
2626

2727
ignore:
2828
- "**/*_generated.*"
29+
- "**/*.pb.go"
2930
- "pkg/config/**/*.*"
3031

3132
github_checks:

0 commit comments

Comments
 (0)