Skip to content

Commit edfc8fa

Browse files
eahydraFillZpp
authored andcommitted
koord-descheduler: limits frequently migrated workloads (#950)
Signed-off-by: Joseph <joseph.t.lee@outlook.com> Signed-off-by: Siyu Wang <FillZpp.pub@gmail.com>
1 parent da5f0a8 commit edfc8fa

File tree

13 files changed

+445
-14
lines changed

13 files changed

+445
-14
lines changed

go.mod

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ require (
2121
github.com/onsi/ginkgo v1.16.4
2222
github.com/onsi/gomega v1.15.0
2323
github.com/openkruise/kruise-api v1.3.0
24+
github.com/patrickmn/go-cache v2.1.0+incompatible
2425
github.com/prashantv/gostub v1.1.0
2526
github.com/prometheus/client_golang v1.13.0
2627
github.com/spf13/cobra v1.6.1
@@ -223,6 +224,7 @@ require (
223224

224225
replace (
225226
github.com/google/cadvisor => github.com/koordinator-sh/cadvisor v0.0.0-20220919031936-833eb74e858e
227+
golang.org/x/time => golang.org/x/time v0.3.0
226228
k8s.io/api => k8s.io/api v0.22.6
227229
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.22.6
228230
k8s.io/apimachinery => k8s.io/apimachinery v0.22.6

go.sum

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,7 @@ github.com/openkruise/kruise-api v1.3.0/go.mod h1:9ZX+ycdHKNzcA5ezAf35xOa2Mwfa2B
806806
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
807807
github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8=
808808
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
809+
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
809810
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
810811
github.com/paypal/load-watcher v0.2.1/go.mod h1:MMCDf8aXF5k+K2q6AtMOBZItCvZ3oFAk+zNO4OAtp0w=
811812
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
@@ -1347,14 +1348,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
13471348
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
13481349
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
13491350
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
1350-
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
1351-
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
1352-
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
1353-
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
1354-
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
1355-
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
1356-
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac h1:7zkz7BUtwNFFqcowJ+RIgu2MaV/MapERkDIy+mwPyjs=
1357-
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
1351+
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
1352+
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
13581353
golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
13591354
golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
13601355
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

pkg/descheduler/apis/config/types_pluginargs.go

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ type MigrationControllerArgs struct {
9191
// Default is false
9292
DryRun bool
9393

94+
// MaxConcurrentReconciles is the maximum number of concurrent Reconciles which can be run. Defaults to 1.
95+
MaxConcurrentReconciles int32
96+
9497
// EvictFailedBarePods allows pods without ownerReferences and in failed phase to be evicted.
9598
EvictFailedBarePods bool
9699

@@ -125,8 +128,11 @@ type MigrationControllerArgs struct {
125128
// Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
126129
MaxUnavailablePerWorkload *intstr.IntOrString
127130

128-
// MaxConcurrentReconciles is the maximum number of concurrent Reconciles which can be run. Defaults to 1.
129-
MaxConcurrentReconciles int32
131+
// ObjectLimiters control the frequency of migration/eviction to make it smoother,
132+
// and also protect Pods of the same class from being evicted frequently.
133+
// e.g. limiting the frequency of Pods of the same workload being evicted.
134+
// The default is to set the MigrationLimitObjectWorkload limiter.
135+
ObjectLimiters ObjectLimiterMap
130136

131137
// DefaultJobMode represents the default operating mode of the PodMigrationJob
132138
// Default is PodMigrationJobModeReservationFirst
@@ -145,3 +151,21 @@ type MigrationControllerArgs struct {
145151
// DefaultDeleteOptions defines options when deleting migrated pods and preempted pods through the method specified by EvictionPolicy
146152
DefaultDeleteOptions *metav1.DeleteOptions
147153
}
154+
155+
type MigrationLimitObjectType string
156+
157+
const (
158+
MigrationLimitObjectWorkload MigrationLimitObjectType = "workload"
159+
)
160+
161+
type ObjectLimiterMap map[MigrationLimitObjectType]MigrationObjectLimiter
162+
163+
// MigrationObjectLimiter means that if the specified dimension has multiple migrations within the configured time period
164+
// and exceeds the configured threshold, it will be limited.
165+
type MigrationObjectLimiter struct {
166+
// Duration indicates the time window of the desired limit.
167+
Duration metav1.Duration
168+
// MaxMigrating indicates the maximum number of migrations/evictions allowed within the window time.
169+
// If configured as nil or 0, the maximum number will be calculated according to MaxMigratingPerWorkload.
170+
MaxMigrating *intstr.IntOrString
171+
}

pkg/descheduler/apis/config/v1alpha2/defaults.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ const (
4040
defaultMigrationJobEvictionPolicy = migrationevictor.NativeEvictorName
4141
)
4242

43+
var (
44+
defaultObjectLimiters = map[MigrationLimitObjectType]MigrationObjectLimiter{
45+
MigrationLimitObjectWorkload: {
46+
Duration: metav1.Duration{Duration: 5 * time.Minute},
47+
},
48+
}
49+
)
50+
4351
func addDefaultingFuncs(scheme *runtime.Scheme) error {
4452
return RegisterDefaults(scheme)
4553
}
@@ -215,6 +223,10 @@ func SetDefaults_MigrationControllerArgs(obj *MigrationControllerArgs) {
215223
if obj.EvictionPolicy == "" {
216224
obj.EvictionPolicy = defaultMigrationJobEvictionPolicy
217225
}
226+
227+
if len(obj.ObjectLimiters) == 0 {
228+
obj.ObjectLimiters = defaultObjectLimiters
229+
}
218230
}
219231

220232
func SetDefaults_LowNodeLoadArgs(obj *LowNodeLoadArgs) {

pkg/descheduler/apis/config/v1alpha2/types_pluginargs.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ type MigrationControllerArgs struct {
128128
// Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
129129
MaxUnavailablePerWorkload *intstr.IntOrString `json:"maxUnavailablePerWorkload,omitempty"`
130130

131+
// ObjectLimiters control the frequency of migration/eviction to make it smoother,
132+
// and also protect Pods of the same class from being evicted frequently.
133+
// e.g. limiting the frequency of Pods of the same workload being evicted.
134+
// The default is to set the MigrationLimitObjectWorkload limiter.
135+
ObjectLimiters ObjectLimiterMap `json:"objectLimiters,omitempty"`
136+
131137
// DefaultJobMode represents the default operating mode of the PodMigrationJob
132138
// Default is PodMigrationJobModeReservationFirst
133139
DefaultJobMode string `json:"defaultJobMode,omitempty"`
@@ -145,3 +151,21 @@ type MigrationControllerArgs struct {
145151
// DefaultDeleteOptions defines options when deleting migrated pods and preempted pods through the method specified by EvictionPolicy
146152
DefaultDeleteOptions *metav1.DeleteOptions `json:"defaultDeleteOptions,omitempty"`
147153
}
154+
155+
type MigrationLimitObjectType string
156+
157+
const (
158+
MigrationLimitObjectWorkload MigrationLimitObjectType = "workload"
159+
)
160+
161+
type ObjectLimiterMap map[MigrationLimitObjectType]MigrationObjectLimiter
162+
163+
// MigrationObjectLimiter means that if the specified dimension has multiple migrations within the configured time period
164+
// and exceeds the configured threshold, it will be limited.
165+
type MigrationObjectLimiter struct {
166+
// Duration indicates the time window of the desired limit.
167+
Duration metav1.Duration `json:"duration,omitempty"`
168+
// MaxMigrating indicates the maximum number of migrations/evictions allowed within the window time.
169+
// If configured as 0, the maximum number will be calculated according to MaxMigratingPerWorkload.
170+
MaxMigrating *intstr.IntOrString `json:"maxMigrating,omitempty"`
171+
}

pkg/descheduler/apis/config/v1alpha2/zz_generated.conversion.go

Lines changed: 37 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/descheduler/apis/config/v1alpha2/zz_generated.deepcopy.go

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/descheduler/apis/config/zz_generated.deepcopy.go

Lines changed: 51 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)