@@ -40,6 +40,7 @@ import (
40
40
utilfeature "k8s.io/apiserver/pkg/util/feature"
41
41
"k8s.io/apiserver/pkg/warning"
42
42
"k8s.io/client-go/tools/cache"
43
+ "k8s.io/component-base/featuregate"
43
44
featuregatetesting "k8s.io/component-base/featuregate/testing"
44
45
ptr "k8s.io/utils/ptr"
45
46
@@ -3330,6 +3331,7 @@ func TestStatusPrepareForUpdate(t *testing.T) {
3330
3331
oldPod * api.Pod
3331
3332
newPod * api.Pod
3332
3333
expected * api.Pod
3334
+ features map [featuregate.Feature ]bool
3333
3335
}{
3334
3336
{
3335
3337
description : "preserve old owner references" ,
@@ -3371,7 +3373,10 @@ func TestStatusPrepareForUpdate(t *testing.T) {
3371
3373
},
3372
3374
},
3373
3375
{
3374
- description : "drop disabled status fields" ,
3376
+ description : "drop disabled status fields/InPlacePodVerticalScaling=false" ,
3377
+ features : map [featuregate.Feature ]bool {
3378
+ features .InPlacePodVerticalScaling : false ,
3379
+ },
3375
3380
oldPod : & api.Pod {
3376
3381
ObjectMeta : metav1.ObjectMeta {Name : "pod" },
3377
3382
Status : api.PodStatus {},
@@ -3394,6 +3399,35 @@ func TestStatusPrepareForUpdate(t *testing.T) {
3394
3399
},
3395
3400
},
3396
3401
},
3402
+ {
3403
+ description : "drop disabled status fields/InPlacePodVerticalScaling=true" ,
3404
+ features : map [featuregate.Feature ]bool {
3405
+ features .InPlacePodVerticalScaling : true ,
3406
+ },
3407
+ oldPod : & api.Pod {
3408
+ ObjectMeta : metav1.ObjectMeta {Name : "pod" },
3409
+ Status : api.PodStatus {},
3410
+ },
3411
+ newPod : & api.Pod {
3412
+ ObjectMeta : metav1.ObjectMeta {Name : "pod" },
3413
+ Status : api.PodStatus {
3414
+ ResourceClaimStatuses : []api.PodResourceClaimStatus {
3415
+ {Name : "my-claim" , ResourceClaimName : ptr .To ("pod-my-claim" )},
3416
+ },
3417
+ ContainerStatuses : []api.ContainerStatus {
3418
+ {Resources : & api.ResourceRequirements {}},
3419
+ },
3420
+ },
3421
+ },
3422
+ expected : & api.Pod {
3423
+ ObjectMeta : metav1.ObjectMeta {Name : "pod" },
3424
+ Status : api.PodStatus {
3425
+ ContainerStatuses : []api.ContainerStatus {
3426
+ {Resources : & api.ResourceRequirements {}},
3427
+ },
3428
+ },
3429
+ },
3430
+ },
3397
3431
{
3398
3432
description : "preserve old status.observedGeneration if empty" ,
3399
3433
oldPod : & api.Pod {
@@ -3553,6 +3587,9 @@ func TestStatusPrepareForUpdate(t *testing.T) {
3553
3587
3554
3588
for _ , tc := range testCases {
3555
3589
t .Run (tc .description , func (t * testing.T ) {
3590
+ for f , v := range tc .features {
3591
+ featuregatetesting .SetFeatureGateDuringTest (t , utilfeature .DefaultFeatureGate , f , v )
3592
+ }
3556
3593
StatusStrategy .PrepareForUpdate (genericapirequest .NewContext (), tc .newPod , tc .oldPod )
3557
3594
if ! cmp .Equal (tc .expected , tc .newPod ) {
3558
3595
t .Errorf ("StatusStrategy.PrepareForUpdate() diff = %v" , cmp .Diff (tc .expected , tc .newPod ))
0 commit comments