Skip to content

Commit 6d8be83

Browse files
committed
VPA: fix logs and cleanup TODOs according to review
Signed-off-by: Max Cao <[email protected]>
1 parent 08ba2fb commit 6d8be83

File tree

7 files changed

+170
-195
lines changed

7 files changed

+170
-195
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ var _ = ActuationSuiteE2eDescribe("Actuation", func() {
415415

416416
InstallVPA(f, vpaCRD)
417417

418-
ginkgo.By(fmt.Sprintf("Waiting for in-place update, hoping it won't happen, sleep for %s", VpaEvictionTimeout.String()))
418+
ginkgo.By(fmt.Sprintf("Waiting for in-place update, hoping it won't happen, sleep for %s", VpaInPlaceTimeout.String()))
419419
CheckNoContainersRestarted(f)
420420

421421
ginkgo.By("Waiting for pods to be evicted")
@@ -457,7 +457,7 @@ var _ = ActuationSuiteE2eDescribe("Actuation", func() {
457457

458458
InstallVPA(f, vpaCRD)
459459

460-
ginkgo.By(fmt.Sprintf("Waiting for in-place update, hoping it won't happen, sleep for %s", VpaEvictionTimeout.String()))
460+
ginkgo.By(fmt.Sprintf("Waiting for in-place update, hoping it won't happen, sleep for %s", VpaInPlaceTimeout.String()))
461461
CheckNoContainersRestarted(f)
462462

463463
ginkgo.By("Waiting for pods to be evicted")
@@ -499,7 +499,7 @@ var _ = ActuationSuiteE2eDescribe("Actuation", func() {
499499

500500
InstallVPA(f, vpaCRD)
501501

502-
ginkgo.By(fmt.Sprintf("Waiting for in-place update, hoping it won't happen, sleep for %s", VpaEvictionTimeout.String()))
502+
ginkgo.By(fmt.Sprintf("Waiting for in-place update, hoping it won't happen, sleep for %s", VpaInPlaceTimeout.String()))
503503
CheckNoContainersRestarted(f)
504504

505505
ginkgo.By("Waiting for pods to be evicted")

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ const (
5353
// VpaEvictionTimeout is a timeout for VPA to restart a pod if there are no
5454
// mechanisms blocking it (for example PDB).
5555
VpaEvictionTimeout = 3 * time.Minute
56+
// VpaInPlaceTimeout is a timeout for the VPA to finish in-place resizing a
57+
// pod (time for vpa to request inplace -> InProgress -> done)
58+
VpaInPlaceTimeout = 2 * time.Minute
5659

5760
defaultHamsterReplicas = int32(3)
5861
defaultHamsterBackoffLimit = int32(10)
@@ -459,7 +462,7 @@ func CheckNoPodsEvicted(f *framework.Framework, initialPodSet PodSet) {
459462
// updating containers in-place and checks that no containers were restarted.
460463
func CheckNoContainersRestarted(f *framework.Framework) {
461464
var foundContainerRestarts int32
462-
time.Sleep(VpaEvictionTimeout)
465+
time.Sleep(VpaInPlaceTimeout)
463466
podList, err := GetHamsterPods(f)
464467
for _, pod := range podList.Items {
465468
containerRestarts := getContainerRestarts(pod.Status)

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

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ var _ = UpdaterE2eDescribe("Updater", func() {
8181
ginkgo.By("Waiting for pods to be in-place updated")
8282

8383
//gomega.Expect(err).NotTo(gomega.HaveOccurred())
84+
// TODO(maxcao13): I don't think we need this much complexity for checking inplace, but I won't remove it for now
8485
err := WaitForPodsUpdatedWithoutEviction(f, initialPods, podList)
8586
gomega.Expect(err).NotTo(gomega.HaveOccurred())
8687
})
@@ -120,6 +121,45 @@ var _ = UpdaterE2eDescribe("Updater", func() {
120121
gomega.Expect(err).NotTo(gomega.HaveOccurred())
121122
})
122123

124+
ginkgo.It("does not in-place update pods when there is no recommendation", func() {
125+
const statusUpdateInterval = 10 * time.Second
126+
127+
ginkgo.By("Setting up the Admission Controller status")
128+
stopCh := make(chan struct{})
129+
statusUpdater := status.NewUpdater(
130+
f.ClientSet,
131+
status.AdmissionControllerStatusName,
132+
status.AdmissionControllerStatusNamespace,
133+
statusUpdateInterval,
134+
"e2e test",
135+
)
136+
defer func() {
137+
// Schedule a cleanup of the Admission Controller status.
138+
// Status is created outside the test namespace.
139+
ginkgo.By("Deleting the Admission Controller status")
140+
close(stopCh)
141+
err := f.ClientSet.CoordinationV1().Leases(status.AdmissionControllerStatusNamespace).
142+
Delete(context.TODO(), status.AdmissionControllerStatusName, metav1.DeleteOptions{})
143+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
144+
}()
145+
statusUpdater.Run(stopCh)
146+
147+
podList := setupPodsForUpscalingWithoutRecommendation(f)
148+
if len(podList.Items[0].Spec.Containers[0].ResizePolicy) <= 0 {
149+
// Feature is probably not working here
150+
ginkgo.Skip("Skipping test, InPlacePodVerticalScaling not available")
151+
}
152+
153+
ginkgo.By(fmt.Sprintf("Waiting for pods to be in-place updated, hoping it won't happen, sleep for %s", VpaInPlaceTimeout.String()))
154+
CheckNoContainersRestarted(f)
155+
156+
updatedPodList, err := GetHamsterPods(f)
157+
gomega.Expect(err).NotTo(gomega.HaveOccurred())
158+
for _, pod := range updatedPodList.Items {
159+
gomega.Expect(getCPURequest(pod.Spec)).To(gomega.Equal(ParseQuantityOrDie("100m")))
160+
}
161+
})
162+
123163
ginkgo.It("evicts pods when Admission Controller status available", func() {
124164
const statusUpdateInterval = 10 * time.Second
125165

@@ -265,14 +305,18 @@ func setupPodsForEviction(f *framework.Framework, hamsterCPU, hamsterMemory stri
265305
}
266306

267307
func setupPodsForUpscalingInPlace(f *framework.Framework) *apiv1.PodList {
268-
return setupPodsForInPlace(f, "100m", "100Mi", nil)
308+
return setupPodsForInPlace(f, "100m", "100Mi", nil, true)
269309
}
270310

271311
func setupPodsForDownscalingInPlace(f *framework.Framework, er []*vpa_types.EvictionRequirement) *apiv1.PodList {
272-
return setupPodsForInPlace(f, "500m", "500Mi", er)
312+
return setupPodsForInPlace(f, "500m", "500Mi", er, true)
313+
}
314+
315+
func setupPodsForUpscalingWithoutRecommendation(f *framework.Framework) *apiv1.PodList {
316+
return setupPodsForInPlace(f, "100m", "100Mi", nil, false)
273317
}
274318

275-
func setupPodsForInPlace(f *framework.Framework, hamsterCPU, hamsterMemory string, er []*vpa_types.EvictionRequirement) *apiv1.PodList {
319+
func setupPodsForInPlace(f *framework.Framework, hamsterCPU, hamsterMemory string, er []*vpa_types.EvictionRequirement, withRecommendation bool) *apiv1.PodList {
276320
controller := &autoscaling.CrossVersionObjectReference{
277321
APIVersion: "apps/v1",
278322
Kind: "Deployment",
@@ -285,22 +329,25 @@ func setupPodsForInPlace(f *framework.Framework, hamsterCPU, hamsterMemory strin
285329

286330
ginkgo.By("Setting up a VPA CRD")
287331
containerName := GetHamsterContainerNameByIndex(0)
288-
vpaCRD := test.VerticalPodAutoscaler().
332+
vpaBuilder := test.VerticalPodAutoscaler().
289333
WithName("hamster-vpa").
290334
WithNamespace(f.Namespace.Name).
291335
WithTargetRef(controller).
292336
WithUpdateMode(vpa_types.UpdateModeInPlaceOrRecreate).
293337
WithEvictionRequirements(er).
294-
WithContainer(containerName).
295-
AppendRecommendation(
338+
WithContainer(containerName)
339+
340+
if withRecommendation {
341+
vpaBuilder = vpaBuilder.AppendRecommendation(
296342
test.Recommendation().
297343
WithContainer(containerName).
298344
WithTarget(containerName, "200m").
299345
WithLowerBound(containerName, "200m").
300346
WithUpperBound(containerName, "200m").
301-
GetContainerResources()).
302-
Get()
347+
GetContainerResources())
348+
}
303349

350+
vpaCRD := vpaBuilder.Get()
304351
InstallVPA(f, vpaCRD)
305352

306353
return podList

0 commit comments

Comments
 (0)