Skip to content

Commit 7fb8bd8

Browse files
authored
Merge pull request kubernetes#130905 from tallclair/ippr-beta
[FG:InPlacePodVerticalScaling] Graduate to Beta
2 parents 83f8513 + cd1a5c6 commit 7fb8bd8

File tree

6 files changed

+64
-15
lines changed

6 files changed

+64
-15
lines changed

pkg/api/pod/util_test.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4026,12 +4026,15 @@ func TestValidateAllowSidecarResizePolicy(t *testing.T) {
40264026
}
40274027

40284028
for _, tc := range testCases {
4029-
t.Run(tc.name, func(t *testing.T) {
4030-
gotOptions := GetValidationOptionsFromPodSpecAndMeta(&api.PodSpec{}, tc.oldPodSpec, nil, nil)
4031-
if tc.wantOption != gotOptions.AllowSidecarResizePolicy {
4032-
t.Errorf("Got AllowSidecarResizePolicy=%t, want %t", gotOptions.AllowSidecarResizePolicy, tc.wantOption)
4033-
}
4034-
})
4029+
for _, ippvsEnabled := range []bool{true, false} {
4030+
t.Run(fmt.Sprintf("%s/%t", tc.name, ippvsEnabled), func(t *testing.T) {
4031+
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.InPlacePodVerticalScaling, ippvsEnabled)
4032+
4033+
gotOptions := GetValidationOptionsFromPodSpecAndMeta(&api.PodSpec{}, tc.oldPodSpec, nil, nil)
4034+
expected := tc.wantOption || ippvsEnabled
4035+
assert.Equal(t, expected, gotOptions.AllowSidecarResizePolicy, "AllowSidecarResizePolicy")
4036+
})
4037+
}
40354038
}
40364039
}
40374040

pkg/features/versioned_kube_features.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ var defaultVersionedKubernetesFeatureGates = map[featuregate.Feature]featuregate
403403

404404
InPlacePodVerticalScaling: {
405405
{Version: version.MustParse("1.27"), Default: false, PreRelease: featuregate.Alpha},
406+
{Version: version.MustParse("1.33"), Default: true, PreRelease: featuregate.Beta},
406407
},
407408

408409
InPlacePodVerticalScalingAllocatedStatus: {

pkg/kubelet/kubelet_pods_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3349,6 +3349,10 @@ func Test_generateAPIPodStatus(t *testing.T) {
33493349
},
33503350
},
33513351
}
3352+
withResources := func(cs v1.ContainerStatus) v1.ContainerStatus {
3353+
cs.Resources = &v1.ResourceRequirements{}
3354+
return cs
3355+
}
33523356

33533357
now := metav1.Now()
33543358
normalized_now := now.Rfc3339Copy()
@@ -3725,7 +3729,7 @@ func Test_generateAPIPodStatus(t *testing.T) {
37253729
},
37263730
ContainerStatuses: []v1.ContainerStatus{
37273731
ready(waitingStateWithReason("containerA", "ContainerCreating")),
3728-
ready(withID(runningStateWithStartedAt("containerB", time.Unix(1, 0).UTC()), "://foo")),
3732+
withResources(ready(withID(runningStateWithStartedAt("containerB", time.Unix(1, 0).UTC()), "://foo"))),
37293733
},
37303734
},
37313735
expectedPodReadyToStartContainersCondition: v1.PodCondition{
@@ -3783,8 +3787,8 @@ func Test_generateAPIPodStatus(t *testing.T) {
37833787
{Type: v1.PodScheduled, Status: v1.ConditionTrue},
37843788
},
37853789
ContainerStatuses: []v1.ContainerStatus{
3786-
ready(withID(runningStateWithStartedAt("containerA", time.Unix(1, 0).UTC()), "://c1")),
3787-
ready(withID(runningStateWithStartedAt("containerB", time.Unix(2, 0).UTC()), "://c2")),
3790+
withResources(ready(withID(runningStateWithStartedAt("containerA", time.Unix(1, 0).UTC()), "://c1"))),
3791+
withResources(ready(withID(runningStateWithStartedAt("containerB", time.Unix(2, 0).UTC()), "://c2"))),
37883792
},
37893793
},
37903794
expectedPodReadyToStartContainersCondition: v1.PodCondition{
@@ -4606,11 +4610,6 @@ func TestSortPodIPs(t *testing.T) {
46064610
}
46074611
}
46084612

4609-
// func init() {
4610-
// klog.InitFlags(flag.CommandLine)
4611-
// flag.CommandLine.Lookup("v").Value.Set("5")
4612-
// }
4613-
46144613
func TestConvertToAPIContainerStatusesDataRace(t *testing.T) {
46154614
pod := podWithUIDNameNs("12345", "test-pod", "test-namespace")
46164615

@@ -5170,6 +5169,7 @@ func TestConvertToAPIContainerStatusesForUser(t *testing.T) {
51705169
ContainerID: testContainerID.String(),
51715170
Image: "img",
51725171
State: v1.ContainerState{Running: &v1.ContainerStateRunning{StartedAt: metav1.NewTime(nowTime)}},
5172+
Resources: &v1.ResourceRequirements{},
51735173
User: user,
51745174
},
51755175
}

pkg/kubelet/kuberuntime/kuberuntime_manager_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,10 @@ func verifyActions(t *testing.T, expected, actual *podActions, desc string) {
12621262
actual.ContainersToKill[k] = info
12631263
}
12641264
}
1265+
if expected.ContainersToUpdate == nil && actual.ContainersToUpdate != nil {
1266+
// No need to distinguish empty and nil maps for the test.
1267+
expected.ContainersToUpdate = map[v1.ResourceName][]containerToUpdateInfo{}
1268+
}
12651269
assert.Equal(t, expected, actual, desc)
12661270
}
12671271

pkg/registry/core/pod/strategy_test.go

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040
utilfeature "k8s.io/apiserver/pkg/util/feature"
4141
"k8s.io/apiserver/pkg/warning"
4242
"k8s.io/client-go/tools/cache"
43+
"k8s.io/component-base/featuregate"
4344
featuregatetesting "k8s.io/component-base/featuregate/testing"
4445
ptr "k8s.io/utils/ptr"
4546

@@ -3330,6 +3331,7 @@ func TestStatusPrepareForUpdate(t *testing.T) {
33303331
oldPod *api.Pod
33313332
newPod *api.Pod
33323333
expected *api.Pod
3334+
features map[featuregate.Feature]bool
33333335
}{
33343336
{
33353337
description: "preserve old owner references",
@@ -3371,7 +3373,10 @@ func TestStatusPrepareForUpdate(t *testing.T) {
33713373
},
33723374
},
33733375
{
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+
},
33753380
oldPod: &api.Pod{
33763381
ObjectMeta: metav1.ObjectMeta{Name: "pod"},
33773382
Status: api.PodStatus{},
@@ -3394,6 +3399,35 @@ func TestStatusPrepareForUpdate(t *testing.T) {
33943399
},
33953400
},
33963401
},
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+
},
33973431
{
33983432
description: "preserve old status.observedGeneration if empty",
33993433
oldPod: &api.Pod{
@@ -3553,6 +3587,9 @@ func TestStatusPrepareForUpdate(t *testing.T) {
35533587

35543588
for _, tc := range testCases {
35553589
t.Run(tc.description, func(t *testing.T) {
3590+
for f, v := range tc.features {
3591+
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, f, v)
3592+
}
35563593
StatusStrategy.PrepareForUpdate(genericapirequest.NewContext(), tc.newPod, tc.oldPod)
35573594
if !cmp.Equal(tc.expected, tc.newPod) {
35583595
t.Errorf("StatusStrategy.PrepareForUpdate() diff = %v", cmp.Diff(tc.expected, tc.newPod))

test/compatibility_lifecycle/reference/versioned_feature_list.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,10 @@
565565
lockToDefault: false
566566
preRelease: Alpha
567567
version: "1.27"
568+
- default: true
569+
lockToDefault: false
570+
preRelease: Beta
571+
version: "1.33"
568572
- name: InPlacePodVerticalScalingAllocatedStatus
569573
versionedSpecs:
570574
- default: false

0 commit comments

Comments
 (0)