-
Notifications
You must be signed in to change notification settings - Fork 96
/
system_load_eviction.go
77 lines (63 loc) · 2.7 KB
/
system_load_eviction.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
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 eviction
import "github.com/kubewharf/katalyst-core/pkg/config/agent/dynamic/crd"
type SystemLoadEvictionPluginConfiguration struct {
// SoftThreshold is the soft threshold of system load pressure, it should be an integral multiple of 100, which means
// the real threshold is (SoftThreshold / 100) * CoreNumber
SoftThreshold int64
// HardThreshold is the hard threshold of system load pressure, it should be an integral multiple of 100, which means
// the real threshold is (SoftThreshold / 100) * CoreNumber
HardThreshold int64
// HistorySize is the size of the load metric ring, which is used to calculate the system load
HistorySize int64
// SyncPeriod is the interval in seconds of the plugin fetch the load information
SyncPeriod int64
// CoolDownTimeInSeconds is the cool-down time of the plugin evict pods
CoolDownTime int64
// GracePeriod is the grace period of pod deletion
GracePeriod int64
// the plugin considers the node is facing load pressure only when the ratio of load history which is greater than
// threshold is greater than this percentage
ThresholdMetPercentage float64
}
func NewSystemLoadEvictionPluginConfiguration() *SystemLoadEvictionPluginConfiguration {
return &SystemLoadEvictionPluginConfiguration{}
}
func (l *SystemLoadEvictionPluginConfiguration) ApplyConfiguration(conf *crd.DynamicConfigCRD) {
if aqc := conf.AdminQoSConfiguration; aqc != nil && aqc.Spec.Config.EvictionConfig != nil &&
aqc.Spec.Config.EvictionConfig.SystemLoadPressureEvictionConfig != nil {
config := aqc.Spec.Config.EvictionConfig.SystemLoadPressureEvictionConfig
if config.SoftThreshold != nil {
l.SoftThreshold = *config.SoftThreshold
}
if config.HardThreshold != nil {
l.HardThreshold = *config.HardThreshold
}
if config.HistorySize != nil {
l.HistorySize = *config.HistorySize
}
if config.SyncPeriod != nil {
l.SyncPeriod = *config.SyncPeriod
}
if config.CoolDownTime != nil {
l.CoolDownTime = *config.CoolDownTime
}
if config.GracePeriod != nil {
l.GracePeriod = *config.GracePeriod
}
if config.ThresholdMetPercentage != nil {
l.ThresholdMetPercentage = *config.ThresholdMetPercentage
}
}
}