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

feat: support dynamic config for reclaimed_cores overlaping shared_cores #576

Merged
merged 1 commit into from
May 8, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,24 @@ import (

type AdvisorOptions struct {
*MemoryGuardOptions
*CPURegionOptions
}

func NewAdvisorOptions() *AdvisorOptions {
return &AdvisorOptions{
MemoryGuardOptions: NewMemoryGuardOptions(),
CPURegionOptions: NewCPURegionOptions(),
}
}

func (o *AdvisorOptions) AddFlags(fss *cliflag.NamedFlagSets) {
o.MemoryGuardOptions.AddFlags(fss)
o.CPURegionOptions.AddFlags(fss)
}

func (o *AdvisorOptions) ApplyTo(c *advisor.AdvisorConfiguration) error {
var errList []error
errList = append(errList, o.MemoryGuardOptions.ApplyTo(c.MemoryGuardConfiguration))
errList = append(errList, o.CPURegionOptions.ApplyTo(c.CPURegionConfiguration))
return errors.NewAggregate(errList)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
Copyright 2022 The Katalyst Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package advisor

import (
cliflag "k8s.io/component-base/cli/flag"

"github.com/kubewharf/katalyst-core/pkg/config/agent/dynamic/adminqos/advisor"
)

type CPURegionOptions struct {
AllowSharedCoresOverlapReclaimedCores bool
}

func NewCPURegionOptions() *CPURegionOptions {
return &CPURegionOptions{
AllowSharedCoresOverlapReclaimedCores: false,
}
}

// AddFlags parses the flags to CPURegionOptions
func (o *CPURegionOptions) AddFlags(fss *cliflag.NamedFlagSets) {
fs := fss.FlagSet("cpu-region")
//
fs.BoolVar(&o.AllowSharedCoresOverlapReclaimedCores, "cpu-region-allow-shared-cores-overlap-reclaimed-cores", o.AllowSharedCoresOverlapReclaimedCores,
"set true to allow shared_cores overlap reclaimed_cores")
}

func (o *CPURegionOptions) ApplyTo(c *advisor.CPURegionConfiguration) error {
c.AllowSharedCoresOverlapReclaimedCores = o.AllowSharedCoresOverlapReclaimedCores
return nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewMemoryGuardOptions() *MemoryGuardOptions {
}
}

// AddFlags parses the flags to CPUPressureEvictionOptions
// AddFlags parses the flags to MemoryGuardOptions
func (o *MemoryGuardOptions) AddFlags(fss *cliflag.NamedFlagSets) {
fs := fss.FlagSet("memory-guard")

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/google/cadvisor v0.44.2
github.com/google/uuid v1.3.0
github.com/klauspost/cpuid/v2 v2.2.6
github.com/kubewharf/katalyst-api v0.5.0
github.com/kubewharf/katalyst-api v0.5.1-0.20240508015926-0f4045cf6899
github.com/montanaflynn/stats v0.7.1
github.com/opencontainers/runc v1.1.6
github.com/opencontainers/selinux v1.10.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kubewharf/katalyst-api v0.5.0 h1:wTEfS4/NbhZSRR/zTFiOAkBcE6ZShICjS8VUSxpuGDc=
github.com/kubewharf/katalyst-api v0.5.0/go.mod h1:Y2IeIorxQamF2a3oa0+URztl5QCSty6Jj3zD83R8J9k=
github.com/kubewharf/katalyst-api v0.5.1-0.20240508015926-0f4045cf6899 h1:r3u4VcGjiRGsPnkQRL1IfBRhSX1g1gwvmyCHo9PKUBs=
github.com/kubewharf/katalyst-api v0.5.1-0.20240508015926-0f4045cf6899/go.mod h1:Y2IeIorxQamF2a3oa0+URztl5QCSty6Jj3zD83R8J9k=
github.com/kubewharf/kubelet v1.24.6-kubewharf.8 h1:2e89T/nZTgzaVhyRsZuwEdRk8V8kJXs4PRkgfeG4Ai4=
github.com/kubewharf/kubelet v1.24.6-kubewharf.8/go.mod h1:MxbSZUx3wXztFneeelwWWlX7NAAStJ6expqq7gY2J3c=
github.com/kyoh86/exportloopref v0.1.7/go.mod h1:h1rDl2Kdj97+Kwh4gdz3ujE7XHmH51Q0lUiZ1z4NLj8=
Expand Down
3 changes: 3 additions & 0 deletions pkg/config/agent/dynamic/adminqos/advisor/advisor_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ import "github.com/kubewharf/katalyst-core/pkg/config/agent/dynamic/crd"

type AdvisorConfiguration struct {
*MemoryGuardConfiguration
*CPURegionConfiguration
}

func NewAdvisorConfiguration() *AdvisorConfiguration {
return &AdvisorConfiguration{
MemoryGuardConfiguration: NewMemoryGuardConfiguration(),
CPURegionConfiguration: NewCPURegionConfiguration(),
}
}

func (c *AdvisorConfiguration) ApplyConfiguration(conf *crd.DynamicConfigCRD) {
c.MemoryGuardConfiguration.ApplyConfiguration(conf)
c.CPURegionConfiguration.ApplyConfiguration(conf)
}
38 changes: 38 additions & 0 deletions pkg/config/agent/dynamic/adminqos/advisor/cpu_region.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
Copyright 2022 The Katalyst Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package advisor

import "github.com/kubewharf/katalyst-core/pkg/config/agent/dynamic/crd"

type CPURegionConfiguration struct {
AllowSharedCoresOverlapReclaimedCores bool
}

func NewCPURegionConfiguration() *CPURegionConfiguration {
return &CPURegionConfiguration{
AllowSharedCoresOverlapReclaimedCores: false,
}
}

func (c *CPURegionConfiguration) ApplyConfiguration(conf *crd.DynamicConfigCRD) {
if aqc := conf.AdminQoSConfiguration; aqc != nil &&
aqc.Spec.Config.AdvisorConfig != nil &&
aqc.Spec.Config.AdvisorConfig.CPUAdvisorConfig != nil &&
aqc.Spec.Config.AdvisorConfig.CPUAdvisorConfig.AllowSharedCoresOverlapReclaimedCores != nil {
c.AllowSharedCoresOverlapReclaimedCores = *aqc.Spec.Config.AdvisorConfig.CPUAdvisorConfig.AllowSharedCoresOverlapReclaimedCores
}
}
Loading