Skip to content

Commit d1d4fb5

Browse files
committed
feat: add evictAfterOOMThreshold per vpa
Signed-off-by: Omer Aplatony <[email protected]>
1 parent f197832 commit d1d4fb5

File tree

16 files changed

+535
-24
lines changed

16 files changed

+535
-24
lines changed

vertical-pod-autoscaler/charts/vertical-pod-autoscaler/crds/vpa-v1-crd-gen.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,14 @@ spec:
254254
- jsonPath: .metadata.creationTimestamp
255255
name: Age
256256
type: date
257+
- jsonPath: .spec.updatePolicy.minReplicas
258+
name: MinReplicas
259+
priority: 1
260+
type: integer
261+
- jsonPath: .spec.updatePolicy.evictAfterOOMThreshold
262+
name: OOMThreshold
263+
priority: 1
264+
type: string
257265
name: v1
258266
schema:
259267
openAPIV3Schema:
@@ -425,6 +433,14 @@ spec:
425433
If not specified, all fields in the `PodUpdatePolicy` are set to their
426434
default values.
427435
properties:
436+
evictAfterOOMThreshold:
437+
description: |-
438+
EvictAfterOOMThreshold specifies the time to wait after an OOM event before
439+
considering the pod for eviction. Pods that have OOMed in less than this threshold
440+
since start will be evicted.
441+
format: duration
442+
pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$
443+
type: string
428444
evictionRequirements:
429445
description: |-
430446
EvictionRequirements is a list of EvictionRequirements that need to
@@ -478,6 +494,10 @@ spec:
478494
- Auto
479495
type: string
480496
type: object
497+
x-kubernetes-validations:
498+
- message: evictAfterOOMThreshold must be greater than 0
499+
rule: '!has(self.evictAfterOOMThreshold) || duration(self.evictAfterOOMThreshold)
500+
>= duration(''0s'')'
481501
required:
482502
- targetRef
483503
type: object

vertical-pod-autoscaler/deploy/vpa-v1-crd-gen.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,14 @@ spec:
254254
- jsonPath: .metadata.creationTimestamp
255255
name: Age
256256
type: date
257+
- jsonPath: .spec.updatePolicy.minReplicas
258+
name: MinReplicas
259+
priority: 1
260+
type: integer
261+
- jsonPath: .spec.updatePolicy.evictAfterOOMThreshold
262+
name: OOMThreshold
263+
priority: 1
264+
type: string
257265
name: v1
258266
schema:
259267
openAPIV3Schema:
@@ -425,6 +433,14 @@ spec:
425433
If not specified, all fields in the `PodUpdatePolicy` are set to their
426434
default values.
427435
properties:
436+
evictAfterOOMThreshold:
437+
description: |-
438+
EvictAfterOOMThreshold specifies the time to wait after an OOM event before
439+
considering the pod for eviction. Pods that have OOMed in less than this threshold
440+
since start will be evicted.
441+
format: duration
442+
pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$
443+
type: string
428444
evictionRequirements:
429445
description: |-
430446
EvictionRequirements is a list of EvictionRequirements that need to
@@ -478,6 +494,10 @@ spec:
478494
- Auto
479495
type: string
480496
type: object
497+
x-kubernetes-validations:
498+
- message: evictAfterOOMThreshold must be greater than 0
499+
rule: '!has(self.evictAfterOOMThreshold) || duration(self.evictAfterOOMThreshold)
500+
>= duration(''0s'')'
481501
required:
482502
- targetRef
483503
type: object

vertical-pod-autoscaler/docs/flags.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ This document is auto-generated from the flag definitions in the VPA updater cod
140140
| `add-dir-header` | | | If true, adds the file directory to the header of the log messages |
141141
| `address` | string | ":8943" | The address to expose Prometheus metrics. |
142142
| `alsologtostderr` | | | log to standard error as well as files (no effect when -logtostderr=true) |
143-
| `evict-after-oom-threshold` | | 10m0s | duration Evict pod that has OOMed in less than evict-after-oom-threshold since start. |
143+
| `evict-after-oom-threshold` | | 10m0s | duration The default duration to evict pod that has OOMed in less than evict-after-oom-threshold since start. |
144144
| `eviction-rate-burst` | int | 1 | Burst of pods that can be evicted. |
145145
| `eviction-rate-limit` | float | | Number of pods that can be evicted per seconds. A rate limit set to 0 or -1 will disable<br>the rate limiter. (default -1) |
146146
| `eviction-tolerance` | float | 0.5 | Fraction of replica count that can be evicted for update, if more than one pod can be evicted. |

vertical-pod-autoscaler/e2e/utils/common.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ var RecommenderLabels = map[string]string{"app": "vpa-recommender"}
7070
// HamsterLabels are labels of hamster app
7171
var HamsterLabels = map[string]string{"app": "hamster"}
7272

73+
// OOMLabels are labels for OOM test pods
74+
var OOMLabels = map[string]string{"app": "oom-test"}
75+
7376
// SIGDescribe adds sig-autoscaling tag to test description.
7477
// Takes args that are passed to ginkgo.Describe.
7578
func SIGDescribe(scenario, name string, args ...interface{}) bool {
@@ -226,7 +229,7 @@ func NewNHamstersDeployment(f *framework.Framework, n int) *appsv1.Deployment {
226229
DefaultHamsterReplicas, /*replicas*/
227230
HamsterLabels, /*podLabels*/
228231
GetHamsterContainerNameByIndex(0), /*imageName*/
229-
"registry.k8s.io/ubuntu-slim:0.14", /*image*/
232+
"ubuntu:25.10", /*image*/
230233
appsv1.RollingUpdateDeploymentStrategyType, /*strategyType*/
231234
)
232235
d.ObjectMeta.Namespace = f.Namespace.Name

vertical-pod-autoscaler/e2e/v1/actuation.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ var _ = ActuationSuiteE2eDescribe("Actuation", func() {
203203
utils.InstallVPA(f, vpaCRD)
204204

205205
ginkgo.By("Waiting for pods to be evicted")
206-
err = WaitForPodsEvicted(f, podList)
206+
err = WaitForPodsEvicted(f, podList, utils.PollTimeout)
207207
gomega.Expect(err).NotTo(gomega.HaveOccurred())
208208
})
209209

@@ -276,7 +276,7 @@ var _ = ActuationSuiteE2eDescribe("Actuation", func() {
276276
}, restriction.DeferredResizeUpdateTimeout, 10*time.Second).Should(gomega.Succeed())
277277

278278
ginkgo.By("Waiting for pods to be evicted")
279-
err = WaitForPodsEvicted(f, podList)
279+
err = WaitForPodsEvicted(f, podList, utils.PollTimeout)
280280
gomega.Expect(err).NotTo(gomega.HaveOccurred())
281281
})
282282

@@ -838,7 +838,7 @@ func testEvictsReplicatedPods(f *framework.Framework, controller *autoscaling.Cr
838838
utils.InstallVPA(f, vpaCRD)
839839

840840
ginkgo.By("Waiting for pods to be evicted")
841-
err = WaitForPodsEvicted(f, podList)
841+
err = WaitForPodsEvicted(f, podList, utils.PollTimeout)
842842
gomega.Expect(err).NotTo(gomega.HaveOccurred())
843843
}
844844

@@ -898,7 +898,7 @@ func testEvictsSingletonPodWhenConfigured(f *framework.Framework, controller *au
898898
utils.InstallVPA(f, vpaCRD)
899899

900900
ginkgo.By("Waiting for pods to be evicted")
901-
err = WaitForPodsEvicted(f, podList)
901+
err = WaitForPodsEvicted(f, podList, utils.PollTimeout)
902902
gomega.Expect(err).NotTo(gomega.HaveOccurred())
903903
}
904904

0 commit comments

Comments
 (0)