Skip to content

Commit aba588c

Browse files
committed
Deprecate IPPVSAllocatedStatus: always set allocatedResources with InPlacePodVerticalScaling
1 parent 67bdb11 commit aba588c

File tree

7 files changed

+56
-76
lines changed

7 files changed

+56
-76
lines changed

pkg/api/pod/util.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -800,9 +800,7 @@ func dropDisabledPodStatusFields(podStatus, oldPodStatus *api.PodStatus, podSpec
800800
dropResourcesField(podStatus.ContainerStatuses)
801801
dropResourcesField(podStatus.InitContainerStatuses)
802802
dropResourcesField(podStatus.EphemeralContainerStatuses)
803-
}
804-
if !utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) ||
805-
!utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScalingAllocatedStatus) {
803+
806804
// Drop AllocatedResources field
807805
dropAllocatedResourcesField := func(csl []api.ContainerStatus) {
808806
for i := range csl {

pkg/api/pod/util_test.go

Lines changed: 45 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -2743,64 +2743,55 @@ func TestDropInPlacePodVerticalScaling(t *testing.T) {
27432743
t.Run(fmt.Sprintf("InPlacePodVerticalScaling=%t", ippvsEnabled), func(t *testing.T) {
27442744
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.InPlacePodVerticalScaling, ippvsEnabled)
27452745

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+
}
27572753

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
27992760
}
2800-
}
2761+
dropDisabledFields(&newPod.Spec, nil, oldPodSpec, nil)
2762+
dropDisabledPodStatusFields(&newPod.Status, oldPodStatus, &newPod.Spec, oldPodSpec)
28012763

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+
}
28032793
}
2794+
28042795
})
28052796
}
28062797
}

pkg/features/kube_features.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@ const (
311311
// owner: @tallclair
312312
// kep: http://kep.k8s.io/1287
313313
//
314-
// Enables the AllocatedResources field in container status. This feature requires
314+
// Deprecated: This feature gate is no longer used.
315+
// Was: Enables the AllocatedResources field in container status. This feature requires
315316
// InPlacePodVerticalScaling also be enabled.
316317
InPlacePodVerticalScalingAllocatedStatus featuregate.Feature = "InPlacePodVerticalScalingAllocatedStatus"
317318

@@ -1344,6 +1345,7 @@ var defaultVersionedKubernetesFeatureGates = map[featuregate.Feature]featuregate
13441345

13451346
InPlacePodVerticalScalingAllocatedStatus: {
13461347
{Version: version.MustParse("1.32"), Default: false, PreRelease: featuregate.Alpha},
1348+
{Version: version.MustParse("1.33"), Default: false, PreRelease: featuregate.Deprecated}, // remove in 1.36
13471349
},
13481350

13491351
InPlacePodVerticalScalingExclusiveCPUs: {

pkg/kubelet/kubelet_pods.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2279,9 +2279,7 @@ func (kl *Kubelet) convertToAPIContainerStatuses(pod *v1.Pod, podStatus *kubecon
22792279
allocatedContainer := kubecontainer.GetContainerSpec(pod, cName)
22802280
if allocatedContainer != nil {
22812281
status.Resources = convertContainerStatusResources(allocatedContainer, status, cStatus, oldStatuses)
2282-
if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScalingAllocatedStatus) {
2283-
status.AllocatedResources = allocatedContainer.Resources.Requests
2284-
}
2282+
status.AllocatedResources = allocatedContainer.Resources.Requests
22852283
}
22862284
}
22872285

pkg/kubelet/kubelet_pods_test.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5104,20 +5104,8 @@ func TestConvertToAPIContainerStatusesForResources(t *testing.T) {
51045104
}
51055105
podStatus := testPodStatus(state, resources)
51065106

5107-
for _, enableAllocatedStatus := range []bool{true, false} {
5108-
t.Run(fmt.Sprintf("AllocatedStatus=%t", enableAllocatedStatus), func(t *testing.T) {
5109-
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.InPlacePodVerticalScalingAllocatedStatus, enableAllocatedStatus)
5110-
5111-
expected := tc.Expected
5112-
if !enableAllocatedStatus {
5113-
expected = *expected.DeepCopy()
5114-
expected.AllocatedResources = nil
5115-
}
5116-
5117-
cStatuses := kubelet.convertToAPIContainerStatuses(tPod, podStatus, []v1.ContainerStatus{tc.OldStatus}, tPod.Spec.Containers, false, false)
5118-
assert.Equal(t, expected, cStatuses[0])
5119-
})
5120-
}
5107+
cStatuses := kubelet.convertToAPIContainerStatuses(tPod, podStatus, []v1.ContainerStatus{tc.OldStatus}, tPod.Spec.Containers, false, false)
5108+
assert.Equal(t, tc.Expected, cStatuses[0])
51215109
})
51225110
}
51235111
}

pkg/registry/core/pod/strategy_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3092,7 +3092,6 @@ func TestPodResizePrepareForUpdate(t *testing.T) {
30923092
for _, tc := range tests {
30933093
t.Run(tc.name, func(t *testing.T) {
30943094
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.InPlacePodVerticalScaling, true)
3095-
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.InPlacePodVerticalScalingAllocatedStatus, true)
30963095
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.SidecarContainers, true)
30973096
ctx := context.Background()
30983097
ResizeStrategy.PrepareForUpdate(ctx, tc.newPod, tc.oldPod)

test/compatibility_lifecycle/reference/versioned_feature_list.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,10 @@
581581
lockToDefault: false
582582
preRelease: Alpha
583583
version: "1.32"
584+
- default: false
585+
lockToDefault: false
586+
preRelease: Deprecated
587+
version: "1.33"
584588
- name: InPlacePodVerticalScalingExclusiveCPUs
585589
versionedSpecs:
586590
- default: false

0 commit comments

Comments
 (0)