Skip to content

Commit

Permalink
pap: evict: number of BE pods to evict is based on all pods
Browse files Browse the repository at this point in the history
  • Loading branch information
h-w-chen committed Sep 25, 2024
1 parent 935815f commit c4b473d
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pkg/agent/sysadvisor/plugin/poweraware/evictor/load_evictor.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,31 @@ func (l loadEvictor) isBE(pod *v1.Pod) bool {
}

func (l loadEvictor) Evict(ctx context.Context, targetPercent int) {
pods, err := l.podFetcher.GetPodList(ctx, l.isBE)
pods, err := l.podFetcher.GetPodList(ctx, nil)
if err != nil {
general.Errorf("pap: evict: failed to get pods: %v", err)
return
}
countToEvict := len(pods) * targetPercent / 100

general.InfofV(6, "pap: evict: there are %d BE pods; going to evict %d%%", len(pods), targetPercent)
bePods, err := l.podFetcher.GetPodList(ctx, l.isBE)
if err != nil {
general.Errorf("pap: evict: failed to get BE pods: %v", err)
return
}

general.InfofV(6, "pap: evict: %d pods, %d BE; going to evict BE up to %d%% pods = %d",
len(pods), len(bePods), targetPercent, countToEvict)

// discard pending requests not handled yet; we will provide a new sleet of evict requests anyway
l.podEvictor.Reset(ctx)

// todo: replace this FIFO evict policy with one having sort of randomization
countToLive := len(pods) * targetPercent / 100
for _, p := range pods[:countToLive] {
for i, p := range bePods {
// not care much for returned error as power alert eviction is the best effort by design
if i >= countToEvict {
break
}
_ = l.podEvictor.Evict(ctx, p)
}
}
Expand Down

0 comments on commit c4b473d

Please sign in to comment.