@@ -429,6 +429,23 @@ var _ = SIGDescribe("InplaceVPA", func() {
429
429
return cs .Status .UpdatedAvailableReplicas
430
430
}, 600 * time .Second , 3 * time .Second ).Should (gomega .Equal (int32 (1 )))
431
431
432
+ // add this to avoid the situation where the pod status keeps changing
433
+ // TODO: Remove this for status change optimization, maybe in Kubernetes 1.33.
434
+ ginkgo .By ("Wait for the pod status to be consistent" )
435
+ gomega .Eventually (func () string {
436
+ pods , err = tester .ListPodsForCloneSet (cs .Name )
437
+ gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
438
+ a1 , b1 , c1 := getResourcesInfo (pods [0 ])
439
+ if a1 != a || b1 != b || c1 != c {
440
+ framework .Logf ("updateSpec %v" , a1 )
441
+ framework .Logf ("spec %v" , b1 )
442
+ framework .Logf ("container status %v " , c1 )
443
+ a , b , c = a1 , b1 , c1
444
+ }
445
+ SkipTestWhenCgroupError (pods [0 ])
446
+ return pods [0 ].Status .ContainerStatuses [0 ].ContainerID
447
+ }, 120 * time .Second , 3 * time .Second ).Should (gomega .Not (gomega .Equal (oldContainerStatus .ContainerID )))
448
+
432
449
ginkgo .By ("Verify the containerID changed and restartCount should not be 0" )
433
450
pods , err = tester .ListPodsForCloneSet (cs .Name )
434
451
gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
@@ -588,6 +605,23 @@ var _ = SIGDescribe("InplaceVPA", func() {
588
605
return cs .Status .UpdatedAvailableReplicas
589
606
}, 600 * time .Second , 3 * time .Second ).Should (gomega .Equal (int32 (1 )))
590
607
608
+ // add this to avoid the situation where the pod status keeps changing
609
+ // TODO: Remove this for status change optimization, maybe in Kubernetes 1.33.
610
+ ginkgo .By ("Wait for the pod status to be consistent" )
611
+ gomega .Eventually (func () string {
612
+ pods , err = tester .ListPodsForCloneSet (cs .Name )
613
+ gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
614
+ a1 , b1 , c1 := getResourcesInfo (pods [0 ])
615
+ if a1 != a || b1 != b || c1 != c {
616
+ framework .Logf ("updateSpec %v" , a1 )
617
+ framework .Logf ("spec %v" , b1 )
618
+ framework .Logf ("container status %v " , c1 )
619
+ a , b , c = a1 , b1 , c1
620
+ }
621
+ SkipTestWhenCgroupError (pods [0 ])
622
+ return pods [0 ].Status .ContainerStatuses [0 ].ContainerID
623
+ }, 120 * time .Second , 3 * time .Second ).Should (gomega .Not (gomega .Equal (oldContainerStatus .ContainerID )))
624
+
591
625
ginkgo .By ("Verify the containerID changed and restartCount should be 1" )
592
626
pods , err = tester .ListPodsForCloneSet (cs .Name )
593
627
gomega .Expect (err ).NotTo (gomega .HaveOccurred ())
@@ -899,7 +933,14 @@ var _ = SIGDescribe("InplaceVPA", func() {
899
933
gomega .Expect (redisContainerStatus .RestartCount ).Should (gomega .Equal (int32 (1 )))
900
934
901
935
ginkgo .By ("Verify nginx should be stopped after new redis has started" )
902
- gomega .Expect (nginxContainerStatus .LastTerminationState .Terminated .FinishedAt .After (redisContainerStatus .State .Running .StartedAt .Time .Add (time .Second * 10 ))).
936
+ var t time.Time
937
+ if nginxContainerStatus .LastTerminationState .Terminated != nil {
938
+ t = nginxContainerStatus .LastTerminationState .Terminated .FinishedAt .Time
939
+ } else {
940
+ // fix https://github.com/openkruise/kruise/issues/1925
941
+ t = nginxContainerStatus .State .Running .StartedAt .Time
942
+ }
943
+ gomega .Expect (t .After (redisContainerStatus .State .Running .StartedAt .Time .Add (time .Second * 10 ))).
903
944
Should (gomega .Equal (true ), fmt .Sprintf ("nginx finish at %v is not after redis start %v + 10s" ,
904
945
nginxContainerStatus .LastTerminationState .Terminated .FinishedAt ,
905
946
redisContainerStatus .State .Running .StartedAt ))
0 commit comments