|
| 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 ( |
| 20 | + cliflag "k8s.io/component-base/cli/flag" |
| 21 | + |
| 22 | + "github.com/kubewharf/katalyst-core/pkg/config/agent/dynamic/adminqos/eviction" |
| 23 | +) |
| 24 | + |
| 25 | +type NumaSysCPUPressureEvictionOptions struct { |
| 26 | + EnableEviction bool |
| 27 | + MetricRingSize int |
| 28 | + GracePeriod int64 |
| 29 | + SyncPeriod int64 |
| 30 | + |
| 31 | + ThresholdMetPercentage float64 |
| 32 | + NumaCPUUsageSoftThreshold float64 |
| 33 | + NumaCPUUsageHardThreshold float64 |
| 34 | + NUMASysOverTotalUsageSoftThreshold float64 |
| 35 | + NUMASysOverTotalUsageHardThreshold float64 |
| 36 | + NUMASysOverTotalUsageEvictionThreshold float64 |
| 37 | +} |
| 38 | + |
| 39 | +func NewNumaSysCPUPressureEvictionOptions() NumaSysCPUPressureEvictionOptions { |
| 40 | + return NumaSysCPUPressureEvictionOptions{ |
| 41 | + EnableEviction: false, |
| 42 | + MetricRingSize: 4, |
| 43 | + GracePeriod: 60, |
| 44 | + SyncPeriod: 10, |
| 45 | + |
| 46 | + ThresholdMetPercentage: 0.7, |
| 47 | + NumaCPUUsageSoftThreshold: 0.4, |
| 48 | + NumaCPUUsageHardThreshold: 0.5, |
| 49 | + NUMASysOverTotalUsageSoftThreshold: 0.4, |
| 50 | + NUMASysOverTotalUsageHardThreshold: 0.5, |
| 51 | + NUMASysOverTotalUsageEvictionThreshold: 0.3, |
| 52 | + } |
| 53 | +} |
| 54 | + |
| 55 | +func (o *NumaSysCPUPressureEvictionOptions) AddFlags(fss *cliflag.NamedFlagSets) { |
| 56 | + fs := fss.FlagSet("numa-sys-cpu-pressure-eviction") |
| 57 | + |
| 58 | + fs.BoolVar(&o.EnableEviction, "numa-sys-cpu-pressure-eviction-enable", o.EnableEviction, |
| 59 | + "Enable numa system cpu pressure eviction") |
| 60 | + fs.IntVar(&o.MetricRingSize, "numa-sys-cpu-pressure-eviction-metric-ring-size", o.MetricRingSize, |
| 61 | + "The size of the metric ring for NUMA system CPU pressure") |
| 62 | + fs.Int64Var(&o.GracePeriod, "numa-sys-cpu-pressure-eviction-grace-period", o.GracePeriod, |
| 63 | + "The grace period (in seconds) before evicting pods due to NUMA system CPU pressure") |
| 64 | + fs.Int64Var(&o.SyncPeriod, "numa-sys-cpu-pressure-eviction-sync-period", o.SyncPeriod, |
| 65 | + "The sync period (in seconds) for NUMA system CPU pressure eviction") |
| 66 | + |
| 67 | + fs.Float64Var(&o.ThresholdMetPercentage, "numa-sys-cpu-pressure-eviction-threshold-met-percentage", o.ThresholdMetPercentage, |
| 68 | + "The percentage of NUMA nodes whose system CPU pressure meets the threshold to trigger eviction") |
| 69 | + fs.Float64Var(&o.NumaCPUUsageSoftThreshold, "numa-sys-cpu-pressure-eviction-numa-cpu-usage-soft-threshold", o.NumaCPUUsageSoftThreshold, |
| 70 | + "The soft threshold of NUMA node system CPU usage ratio") |
| 71 | + fs.Float64Var(&o.NumaCPUUsageHardThreshold, "numa-sys-cpu-pressure-eviction-numa-cpu-usage-hard-threshold", o.NumaCPUUsageHardThreshold, |
| 72 | + "The hard threshold of NUMA node system CPU usage ratio") |
| 73 | + fs.Float64Var(&o.NUMASysOverTotalUsageSoftThreshold, "numa-sys-cpu-pressure-eviction-numa-sys-over-total-usage-soft-threshold", o.NUMASysOverTotalUsageSoftThreshold, |
| 74 | + "The soft threshold of NUMA node system CPU pressure over total system CPU usage ratio") |
| 75 | + fs.Float64Var(&o.NUMASysOverTotalUsageHardThreshold, "numa-sys-cpu-pressure-eviction-numa-sys-over-total-usage-hard-threshold", o.NUMASysOverTotalUsageHardThreshold, |
| 76 | + "The hard threshold of NUMA node system CPU pressure over total system CPU usage ratio") |
| 77 | + fs.Float64Var(&o.NUMASysOverTotalUsageEvictionThreshold, "numa-sys-cpu-pressure-eviction-numa-sys-over-total-usage-eviction-threshold", o.NUMASysOverTotalUsageEvictionThreshold, |
| 78 | + "The eviction threshold of NUMA node system CPU pressure over total system CPU usage ratio") |
| 79 | +} |
| 80 | + |
| 81 | +func (o *NumaSysCPUPressureEvictionOptions) ApplyTo(c *eviction.NumaSysCPUPressureEvictionConfiguration) error { |
| 82 | + c.EnableEviction = o.EnableEviction |
| 83 | + c.MetricRingSize = o.MetricRingSize |
| 84 | + c.GracePeriod = o.GracePeriod |
| 85 | + c.SyncPeriod = o.SyncPeriod |
| 86 | + |
| 87 | + c.ThresholdMetPercentage = o.ThresholdMetPercentage |
| 88 | + c.NumaCPUUsageSoftThreshold = o.NumaCPUUsageSoftThreshold |
| 89 | + c.NumaCPUUsageHardThreshold = o.NumaCPUUsageHardThreshold |
| 90 | + c.NUMASysOverTotalUsageSoftThreshold = o.NUMASysOverTotalUsageSoftThreshold |
| 91 | + c.NUMASysOverTotalUsageHardThreshold = o.NUMASysOverTotalUsageHardThreshold |
| 92 | + c.NUMASysOverTotalUsageEvictionThreshold = o.NUMASysOverTotalUsageEvictionThreshold |
| 93 | + |
| 94 | + return nil |
| 95 | +} |
0 commit comments