Skip to content

Commit 7f9b9c4

Browse files
committed
fixup! VPA: Allow updater to actuate InPlaceOrRecreate updates
Signed-off-by: Max Cao <[email protected]>
1 parent ea08e09 commit 7f9b9c4

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

vertical-pod-autoscaler/pkg/updater/eviction/pods_eviction_restriction.go

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ func (e *podsEvictionRestrictionImpl) CanEvict(pod *apiv1.Pod) bool {
120120
}
121121
if present {
122122
shouldBeAlive := singleGroupStats.configured - singleGroupStats.evictionTolerance
123+
actuallyAlive := singleGroupStats.running - (singleGroupStats.evicted + singleGroupStats.inPlaceUpdating)
124+
123125
klog.V(4).InfoS("Pod disruption tolerance",
124126
"pod", klog.KObj(pod),
125127
"running", singleGroupStats.running,
@@ -128,17 +130,17 @@ func (e *podsEvictionRestrictionImpl) CanEvict(pod *apiv1.Pod) bool {
128130
"evicted", singleGroupStats.evicted,
129131
"updating", singleGroupStats.inPlaceUpdating)
130132
if IsInPlaceUpdating(pod) {
131-
if singleGroupStats.running-(singleGroupStats.evicted+(singleGroupStats.inPlaceUpdating-1)) > shouldBeAlive {
132-
klog.V(4).InfoS("Would be able to evict, but already resizing", "pod", klog.KObj(pod))
133+
if (actuallyAlive - 1) > shouldBeAlive { // -1 because this pod is the one being in-place updated
133134
if pod.Status.Resize == apiv1.PodResizeStatusInfeasible || pod.Status.Resize == apiv1.PodResizeStatusDeferred {
134135
klog.InfoS("Attempted in-place resize was impossible, should now evict", "pod", klog.KObj(pod), "resizePolicy", pod.Status.Resize)
135136
return true
136137
}
137138
}
139+
klog.V(4).InfoS("Would be able to evict, but already resizing", "pod", klog.KObj(pod))
138140
return false
139141
}
140142

141-
if singleGroupStats.running-(singleGroupStats.evicted+singleGroupStats.inPlaceUpdating) > shouldBeAlive {
143+
if actuallyAlive > shouldBeAlive {
142144
return true
143145
}
144146
// If all pods are running and eviction tolerance is small evict 1 pod.
@@ -463,34 +465,33 @@ func (e *podsEvictionRestrictionImpl) CanInPlaceUpdate(pod *apiv1.Pod) bool {
463465
klog.V(4).InfoS("Can't resize pending pod", "pod", klog.KObj(pod))
464466
return false
465467
}
466-
// TODO(maxcao13): May need to rename evictionTolerance to disruptionTolerance
468+
// TODO: Rename evictionTolerance to disruptionTolerance?
467469
if present {
468-
// minimum number of pods that should be running to tolerate disruptions
469470
shouldBeAlive := singleGroupStats.configured - singleGroupStats.evictionTolerance
470-
// number of pods that are actually running
471471
actuallyAlive := singleGroupStats.running - (singleGroupStats.evicted + singleGroupStats.inPlaceUpdating)
472-
klog.V(4).InfoS("Checking pod disruption tolerance",
473-
"pod", klog.KObj(pod),
474-
"configuredPods", singleGroupStats.configured,
475-
"runningPods", singleGroupStats.running,
476-
"evictedPods", singleGroupStats.evicted,
477-
"inPlaceUpdatingPods", singleGroupStats.inPlaceUpdating,
478-
"evictionTolerance", singleGroupStats.evictionTolerance,
479-
"shouldBeAlive", shouldBeAlive,
480-
"actuallyAlive", actuallyAlive,
481-
)
472+
eligibleForInPlaceUpdate := false
473+
482474
if actuallyAlive > shouldBeAlive {
483-
klog.V(4).InfoS("Pod can be resized in-place; more pods are running than required", "pod", klog.KObj(pod), "shouldBeAlive", shouldBeAlive, "actuallyAlive", actuallyAlive)
484-
return true
475+
eligibleForInPlaceUpdate = true
485476
}
486477

487478
// If all pods are running, no pods are being evicted or updated, and eviction tolerance is small, we can resize in-place
488479
if singleGroupStats.running == singleGroupStats.configured &&
489480
singleGroupStats.evictionTolerance == 0 &&
490481
singleGroupStats.evicted == 0 && singleGroupStats.inPlaceUpdating == 0 {
491-
klog.V(4).InfoS("Pod can be resized in-place; all pods are running and eviction tolerance is 0", "pod", klog.KObj(pod))
492-
return true
482+
eligibleForInPlaceUpdate = true
493483
}
484+
485+
klog.V(4).InfoS("Pod disruption tolerance",
486+
"pod", klog.KObj(pod),
487+
"configuredPods", singleGroupStats.configured,
488+
"runningPods", singleGroupStats.running,
489+
"evictedPods", singleGroupStats.evicted,
490+
"inPlaceUpdatingPods", singleGroupStats.inPlaceUpdating,
491+
"evictionTolerance", singleGroupStats.evictionTolerance,
492+
"eligibleForInPlaceUpdate", eligibleForInPlaceUpdate,
493+
)
494+
return eligibleForInPlaceUpdate
494495
}
495496
}
496497
return false

0 commit comments

Comments
 (0)