Skip to content

Commit

Permalink
koord-descheduler: support ignore expected replicas argument (#1419)
Browse files Browse the repository at this point in the history
Signed-off-by: lisen <lisen@youzan.com>
Co-authored-by: lisen <lisen@youzan.com>
  • Loading branch information
leason00 and lisen committed Jun 30, 2023
1 parent cc37c24 commit c09ef91
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 5 deletions.
4 changes: 4 additions & 0 deletions pkg/descheduler/apis/config/types_pluginargs.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ type MigrationControllerArgs struct {
// Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
MaxUnavailablePerWorkload *intstr.IntOrString

// SkipCheckExpectedReplicas if enabled, it will allow eviction expectedReplicas equals maxUnavailable or maxMigrating.
// Default is false
SkipCheckExpectedReplicas *bool

// ObjectLimiters control the frequency of migration/eviction to make it smoother,
// and also protect Pods of the same class from being evicted frequently.
// e.g. limiting the frequency of Pods of the same workload being evicted.
Expand Down
4 changes: 4 additions & 0 deletions pkg/descheduler/apis/config/v1alpha2/types_pluginargs.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ type MigrationControllerArgs struct {
// Value can be an absolute number (ex: 5) or a percentage of desired pods (ex: 10%).
MaxUnavailablePerWorkload *intstr.IntOrString `json:"maxUnavailablePerWorkload,omitempty"`

// SkipCheckExpectedReplicas if enabled, it will allow eviction expectedReplicas equals maxUnavailable or maxMigrating.
// Default is false
SkipCheckExpectedReplicas *bool `json:"skipCheckExpectedReplicas,omitempty"`

// ObjectLimiters control the frequency of migration/eviction to make it smoother,
// and also protect Pods of the same class from being evicted frequently.
// e.g. limiting the frequency of Pods of the same workload being evicted.
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/descheduler/apis/config/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/descheduler/apis/config/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions pkg/descheduler/controllers/migration/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,13 @@ func (r *Reconciler) filterMaxMigratingOrUnavailablePerWorkload(pod *corev1.Pod)
return false
}

// TODO(joseph): There are a few special scenarios where should we allow eviction?
if expectedReplicas == 1 || int(expectedReplicas) == maxMigrating || int(expectedReplicas) == maxUnavailable {
klog.Warningf("maxMigrating(%d) or maxUnavailable(%d) equals to the replicas(%d) of the workload %s/%s/%s(%s) of Pod %q, or the replicas equals to 1, please increase the replicas or update the defense configurations",
maxMigrating, maxUnavailable, expectedReplicas, ownerRef.Name, ownerRef.Kind, ownerRef.APIVersion, ownerRef.UID, klog.KObj(pod))
return false
if r.args.SkipCheckExpectedReplicas == nil || !*r.args.SkipCheckExpectedReplicas {
// TODO(joseph): There are a few special scenarios where should we allow eviction?
if expectedReplicas == 1 || int(expectedReplicas) == maxMigrating || int(expectedReplicas) == maxUnavailable {
klog.Warningf("maxMigrating(%d) or maxUnavailable(%d) equals to the replicas(%d) of the workload %s/%s/%s(%s) of Pod %q, or the replicas equals to 1, please increase the replicas or update the defense configurations",
maxMigrating, maxUnavailable, expectedReplicas, ownerRef.Name, ownerRef.Kind, ownerRef.APIVersion, ownerRef.UID, klog.KObj(pod))
return false
}
}

var expectPhases []sev1alpha1.PodMigrationJobPhase
Expand Down

0 comments on commit c09ef91

Please sign in to comment.