@@ -2743,64 +2743,55 @@ func TestDropInPlacePodVerticalScaling(t *testing.T) {
2743
2743
t .Run (fmt .Sprintf ("InPlacePodVerticalScaling=%t" , ippvsEnabled ), func (t * testing.T ) {
2744
2744
featuregatetesting .SetFeatureGateDuringTest (t , utilfeature .DefaultFeatureGate , features .InPlacePodVerticalScaling , ippvsEnabled )
2745
2745
2746
- for _ , allocatedStatusEnabled := range []bool {true , false } {
2747
- t .Run (fmt .Sprintf ("AllocatedStatus=%t" , allocatedStatusEnabled ), func (t * testing.T ) {
2748
- featuregatetesting .SetFeatureGateDuringTest (t , utilfeature .DefaultFeatureGate , features .InPlacePodVerticalScalingAllocatedStatus , allocatedStatusEnabled )
2749
-
2750
- for _ , oldPodInfo := range podInfo {
2751
- for _ , newPodInfo := range podInfo {
2752
- oldPodHasInPlaceVerticalScaling , oldPod := oldPodInfo .hasInPlaceVerticalScaling , oldPodInfo .pod ()
2753
- newPodHasInPlaceVerticalScaling , newPod := newPodInfo .hasInPlaceVerticalScaling , newPodInfo .pod ()
2754
- if newPod == nil {
2755
- continue
2756
- }
2746
+ for _ , oldPodInfo := range podInfo {
2747
+ for _ , newPodInfo := range podInfo {
2748
+ oldPodHasInPlaceVerticalScaling , oldPod := oldPodInfo .hasInPlaceVerticalScaling , oldPodInfo .pod ()
2749
+ newPodHasInPlaceVerticalScaling , newPod := newPodInfo .hasInPlaceVerticalScaling , newPodInfo .pod ()
2750
+ if newPod == nil {
2751
+ continue
2752
+ }
2757
2753
2758
- t .Run (fmt .Sprintf ("old pod %v, new pod %v" , oldPodInfo .description , newPodInfo .description ), func (t * testing.T ) {
2759
- var oldPodSpec * api.PodSpec
2760
- var oldPodStatus * api.PodStatus
2761
- if oldPod != nil {
2762
- oldPodSpec = & oldPod .Spec
2763
- oldPodStatus = & oldPod .Status
2764
- }
2765
- dropDisabledFields (& newPod .Spec , nil , oldPodSpec , nil )
2766
- dropDisabledPodStatusFields (& newPod .Status , oldPodStatus , & newPod .Spec , oldPodSpec )
2767
-
2768
- // old pod should never be changed
2769
- if ! reflect .DeepEqual (oldPod , oldPodInfo .pod ()) {
2770
- t .Errorf ("old pod changed: %v" , cmp .Diff (oldPod , oldPodInfo .pod ()))
2771
- }
2772
-
2773
- switch {
2774
- case ippvsEnabled || oldPodHasInPlaceVerticalScaling :
2775
- // new pod shouldn't change if feature enabled or if old pod has ResizePolicy set
2776
- expected := newPodInfo .pod ()
2777
- if ! ippvsEnabled || ! allocatedStatusEnabled {
2778
- expected .Status .ContainerStatuses [0 ].AllocatedResources = nil
2779
- }
2780
- if ! reflect .DeepEqual (newPod , expected ) {
2781
- t .Errorf ("new pod changed: %v" , cmp .Diff (newPod , expected ))
2782
- }
2783
- case newPodHasInPlaceVerticalScaling :
2784
- // new pod should be changed
2785
- if reflect .DeepEqual (newPod , newPodInfo .pod ()) {
2786
- t .Errorf ("new pod was not changed" )
2787
- }
2788
- // new pod should not have ResizePolicy
2789
- if ! reflect .DeepEqual (newPod , podWithoutInPlaceVerticalScaling ()) {
2790
- t .Errorf ("new pod has ResizePolicy: %v" , cmp .Diff (newPod , podWithoutInPlaceVerticalScaling ()))
2791
- }
2792
- default :
2793
- // new pod should not need to be changed
2794
- if ! reflect .DeepEqual (newPod , newPodInfo .pod ()) {
2795
- t .Errorf ("new pod changed: %v" , cmp .Diff (newPod , newPodInfo .pod ()))
2796
- }
2797
- }
2798
- })
2754
+ t .Run (fmt .Sprintf ("old pod %v, new pod %v" , oldPodInfo .description , newPodInfo .description ), func (t * testing.T ) {
2755
+ var oldPodSpec * api.PodSpec
2756
+ var oldPodStatus * api.PodStatus
2757
+ if oldPod != nil {
2758
+ oldPodSpec = & oldPod .Spec
2759
+ oldPodStatus = & oldPod .Status
2799
2760
}
2800
- }
2761
+ dropDisabledFields (& newPod .Spec , nil , oldPodSpec , nil )
2762
+ dropDisabledPodStatusFields (& newPod .Status , oldPodStatus , & newPod .Spec , oldPodSpec )
2801
2763
2802
- })
2764
+ // old pod should never be changed
2765
+ if ! reflect .DeepEqual (oldPod , oldPodInfo .pod ()) {
2766
+ t .Errorf ("old pod changed: %v" , cmp .Diff (oldPod , oldPodInfo .pod ()))
2767
+ }
2768
+
2769
+ switch {
2770
+ case ippvsEnabled || oldPodHasInPlaceVerticalScaling :
2771
+ // new pod shouldn't change if feature enabled or if old pod has ResizePolicy set
2772
+ expected := newPodInfo .pod ()
2773
+ if ! reflect .DeepEqual (newPod , expected ) {
2774
+ t .Errorf ("new pod changed: %v" , cmp .Diff (newPod , expected ))
2775
+ }
2776
+ case newPodHasInPlaceVerticalScaling :
2777
+ // new pod should be changed
2778
+ if reflect .DeepEqual (newPod , newPodInfo .pod ()) {
2779
+ t .Errorf ("new pod was not changed" )
2780
+ }
2781
+ // new pod should not have ResizePolicy
2782
+ if ! reflect .DeepEqual (newPod , podWithoutInPlaceVerticalScaling ()) {
2783
+ t .Errorf ("new pod has ResizePolicy: %v" , cmp .Diff (newPod , podWithoutInPlaceVerticalScaling ()))
2784
+ }
2785
+ default :
2786
+ // new pod should not need to be changed
2787
+ if ! reflect .DeepEqual (newPod , newPodInfo .pod ()) {
2788
+ t .Errorf ("new pod changed: %v" , cmp .Diff (newPod , newPodInfo .pod ()))
2789
+ }
2790
+ }
2791
+ })
2792
+ }
2803
2793
}
2794
+
2804
2795
})
2805
2796
}
2806
2797
}
0 commit comments