github.com/kubewharf/katalyst-core@v0.5.3/pkg/config/agent/dynamic/adminqos/eviction/eviction_base.go (about) 1 /* 2 Copyright 2022 The Katalyst Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package eviction 18 19 import "github.com/kubewharf/katalyst-core/pkg/config/agent/dynamic/crd" 20 21 type EvictionConfiguration struct { 22 // Dryrun plugins is the list of plugins to dryrun 23 // '*' means "all dryrun by default" 24 // 'foo' means "dryrun 'foo'" 25 // first item for a particular name wins 26 DryRun []string 27 28 *CPUPressureEvictionConfiguration 29 *MemoryPressureEvictionConfiguration 30 *RootfsPressureEvictionConfiguration 31 *ReclaimedResourcesEvictionConfiguration 32 *SystemLoadEvictionPluginConfiguration 33 } 34 35 func NewEvictionConfiguration() *EvictionConfiguration { 36 return &EvictionConfiguration{ 37 CPUPressureEvictionConfiguration: NewCPUPressureEvictionConfiguration(), 38 MemoryPressureEvictionConfiguration: NewMemoryPressureEvictionPluginConfiguration(), 39 RootfsPressureEvictionConfiguration: NewRootfsPressureEvictionPluginConfiguration(), 40 ReclaimedResourcesEvictionConfiguration: NewReclaimedResourcesEvictionConfiguration(), 41 SystemLoadEvictionPluginConfiguration: NewSystemLoadEvictionPluginConfiguration(), 42 } 43 } 44 45 func (c *EvictionConfiguration) ApplyConfiguration(conf *crd.DynamicConfigCRD) { 46 if aqc := conf.AdminQoSConfiguration; aqc != nil && aqc.Spec.Config.EvictionConfig != nil && 47 aqc.Spec.Config.EvictionConfig.DryRun != nil { 48 c.DryRun = aqc.Spec.Config.EvictionConfig.DryRun 49 } 50 51 c.CPUPressureEvictionConfiguration.ApplyConfiguration(conf) 52 c.MemoryPressureEvictionConfiguration.ApplyConfiguration(conf) 53 c.RootfsPressureEvictionConfiguration.ApplyTo(conf) 54 c.ReclaimedResourcesEvictionConfiguration.ApplyConfiguration(conf) 55 c.SystemLoadEvictionPluginConfiguration.ApplyConfiguration(conf) 56 }