Skip to content

Commit 35c6524

Browse files
authored
scheduler: add ElasticQuota arg to control preemption of default quota (#2413) (#2449)
Signed-off-by: Lennon Chin <[email protected]>
1 parent e5bee0d commit 35c6524

File tree

10 files changed

+55
-6
lines changed

10 files changed

+55
-6
lines changed

pkg/scheduler/apis/config/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ type ElasticQuotaArgs struct {
215215
// EnableRuntimeQuota if false, use max instead of runtime for all checks.
216216
EnableRuntimeQuota bool
217217

218+
// DisableDefaultQuotaPreemption if true, will not preempt pods in default quota.
219+
DisableDefaultQuotaPreemption bool
220+
218221
// HookPlugins is expected to be configured with enabled hook plugins
219222
HookPlugins []HookPluginConf
220223
}

pkg/scheduler/apis/config/v1/defaults.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ var (
6969

7070
defaultQuotaGroupNamespace = "koordinator-system"
7171

72-
defaultMonitorAllQuotas = pointer.Bool(false)
73-
defaultEnableCheckParentQuota = pointer.Bool(false)
74-
defaultEnableRuntimeQuota = pointer.Bool(true)
72+
defaultMonitorAllQuotas = pointer.Bool(false)
73+
defaultEnableCheckParentQuota = pointer.Bool(false)
74+
defaultEnableRuntimeQuota = pointer.Bool(true)
75+
defaultDisableDefaultQuotaPreemption = pointer.Bool(true)
7576

7677
defaultTimeout = 600 * time.Second
7778
defaultControllerWorkers = 1
@@ -190,6 +191,9 @@ func SetDefaults_ElasticQuotaArgs(obj *ElasticQuotaArgs) {
190191
if obj.EnableRuntimeQuota == nil {
191192
obj.EnableRuntimeQuota = defaultEnableRuntimeQuota
192193
}
194+
if obj.DisableDefaultQuotaPreemption == nil {
195+
obj.DisableDefaultQuotaPreemption = defaultDisableDefaultQuotaPreemption
196+
}
193197
}
194198

195199
func SetDefaults_CoschedulingArgs(obj *CoschedulingArgs) {

pkg/scheduler/apis/config/v1/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ type ElasticQuotaArgs struct {
209209
// EnableRuntimeQuota if false, use max instead of runtime for all checks.
210210
EnableRuntimeQuota *bool `json:"enableRuntimeQuota,omitempty"`
211211

212+
// DisableDefaultQuotaPreemption if true, will not preempt pods in default quota.
213+
DisableDefaultQuotaPreemption *bool `json:"disableDefaultQuotaPreemption,omitempty"`
214+
212215
// HookPlugins is expected to be configured with enabled hook plugins
213216
HookPlugins []HookPluginConf `json:"hookPlugins,omitempty"`
214217
}

pkg/scheduler/apis/config/v1/zz_generated.conversion.go

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

pkg/scheduler/apis/config/v1/zz_generated.deepcopy.go

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

pkg/scheduler/apis/config/v1beta3/defaults.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ var (
6969

7070
defaultQuotaGroupNamespace = "koordinator-system"
7171

72-
defaultMonitorAllQuotas = pointer.Bool(false)
73-
defaultEnableCheckParentQuota = pointer.Bool(false)
74-
defaultEnableRuntimeQuota = pointer.Bool(true)
72+
defaultMonitorAllQuotas = pointer.Bool(false)
73+
defaultEnableCheckParentQuota = pointer.Bool(false)
74+
defaultEnableRuntimeQuota = pointer.Bool(true)
75+
defaultDisableDefaultQuotaPreemption = pointer.Bool(true)
7576

7677
defaultTimeout = 600 * time.Second
7778
defaultControllerWorkers = 1
@@ -190,6 +191,9 @@ func SetDefaults_ElasticQuotaArgs(obj *ElasticQuotaArgs) {
190191
if obj.EnableRuntimeQuota == nil {
191192
obj.EnableRuntimeQuota = defaultEnableRuntimeQuota
192193
}
194+
if obj.DisableDefaultQuotaPreemption == nil {
195+
obj.DisableDefaultQuotaPreemption = defaultDisableDefaultQuotaPreemption
196+
}
193197
}
194198

195199
func SetDefaults_CoschedulingArgs(obj *CoschedulingArgs) {

pkg/scheduler/apis/config/v1beta3/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ type ElasticQuotaArgs struct {
209209
// EnableRuntimeQuota if false, use max instead of runtime for all checks.
210210
EnableRuntimeQuota *bool `json:"enableRuntimeQuota,omitempty"`
211211

212+
// DisableDefaultQuotaPreemption if true, will not preempt pods in default quota.
213+
DisableDefaultQuotaPreemption *bool `json:"disableDefaultQuotaPreemption,omitempty"`
214+
212215
// HookPlugins is expected to be configured with enabled hook plugins
213216
HookPlugins []HookPluginConf `json:"hookPlugins,omitempty"`
214217
}

pkg/scheduler/apis/config/v1beta3/zz_generated.conversion.go

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

pkg/scheduler/apis/config/v1beta3/zz_generated.deepcopy.go

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

pkg/scheduler/plugins/elasticquota/preempt.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,5 +290,15 @@ func (g *Plugin) canPreempt(pod, victim *corev1.Pod) bool {
290290
podQuotaName := g.getPodAssociateQuotaName(pod)
291291
vicQuotaName := g.getPodAssociateQuotaName(victim)
292292

293+
// The quota of pods that do not actively set through annotation will be recognized as the default quota.
294+
// In some scenarios, many important pods are not scheduled by Koordinator, and their quotas are
295+
// also recognized as default quota, this will cause the eviction operation to identify these important
296+
// pods as victim pods, which is risky. When DisableDefaultQuotaPreemption is set to true, these pods can
297+
// be avoided from being evicted.
298+
if g.pluginArgs.DisableDefaultQuotaPreemption &&
299+
extension.DefaultQuotaName == vicQuotaName {
300+
return false
301+
}
302+
293303
return podPri > vicPri && podQuotaName == vicQuotaName
294304
}

0 commit comments

Comments
 (0)