Skip to content

Commit

Permalink
Perceiving the health status of cluster scheduling results in gracefu…
Browse files Browse the repository at this point in the history
…l evictions

Signed-off-by: changzhen <changzhen5@huawei.com>
  • Loading branch information
XiShanYongYe-Chang committed Aug 25, 2022
1 parent 23ec2af commit 35adaad
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions pkg/controllers/gracefuleviction/evictiontask.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,39 @@ func assessEvictionTasks(bindingSpec workv1alpha2.ResourceBindingSpec,
}

func assessSingleTask(task workv1alpha2.GracefulEvictionTask, opt assessmentOption) *workv1alpha2.GracefulEvictionTask {
// TODO(): gradually evict replica as per observed status.

// task exceeds timeout
if metav1.Now().After(task.CreationTimestamp.Add(opt.timeout)) {
return nil
}

// TODO(): gradually evict replica as per observed status.
if analyzeHealthOfScheduleResult(opt) {
return nil
}

return &task
}

func analyzeHealthOfScheduleResult(opt assessmentOption) bool {
for _, targetCluster := range opt.scheduleResult {
var matchStatus *workv1alpha2.AggregatedStatusItem
for _, aggregatedStatus := range opt.observedStatus {
if aggregatedStatus.ClusterName == targetCluster.Name {
matchStatus = &aggregatedStatus
break
}
}

if matchStatus == nil ||
matchStatus.Health == workv1alpha2.ResourceUnhealthy ||
matchStatus.Health == workv1alpha2.ResourceUnknown {
return false
}
}

return true
}

func nextRetry(tasks []workv1alpha2.GracefulEvictionTask, timeout time.Duration, timeNow time.Time) time.Duration {
if len(tasks) == 0 {
return 0
Expand Down

0 comments on commit 35adaad

Please sign in to comment.