@@ -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
267307func setupPodsForUpscalingInPlace (f * framework.Framework ) * apiv1.PodList {
268- return setupPodsForInPlace (f , "100m" , "100Mi" , nil )
308+ return setupPodsForInPlace (f , "100m" , "100Mi" , nil , true )
269309}
270310
271311func 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