Skip to content

Commit 30b34fb

Browse files
committed
Don't read AllocatedResources from PodStatus during admission
1 parent 8e6d788 commit 30b34fb

File tree

2 files changed

+1
-32
lines changed

2 files changed

+1
-32
lines changed

pkg/kubelet/cm/cpumanager/policy_static.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -474,21 +474,6 @@ func (p *staticPolicy) guaranteedCPUs(pod *v1.Pod, container *v1.Container) int
474474
return 0
475475
}
476476
cpuQuantity := container.Resources.Requests[v1.ResourceCPU]
477-
// In-place pod resize feature makes Container.Resources field mutable for CPU & memory.
478-
// AllocatedResources holds the value of Container.Resources.Requests when the pod was admitted.
479-
// We should return this value because this is what kubelet agreed to allocate for the container
480-
// and the value configured with runtime.
481-
if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) {
482-
containerStatuses := pod.Status.ContainerStatuses
483-
if podutil.IsRestartableInitContainer(container) {
484-
if len(pod.Status.InitContainerStatuses) != 0 {
485-
containerStatuses = append(containerStatuses, pod.Status.InitContainerStatuses...)
486-
}
487-
}
488-
if cs, ok := podutil.GetContainerStatus(containerStatuses, container.Name); ok {
489-
cpuQuantity = cs.AllocatedResources[v1.ResourceCPU]
490-
}
491-
}
492477
cpuValue := cpuQuantity.Value()
493478
if cpuValue*1000 != cpuQuantity.MilliValue() {
494479
klog.V(5).InfoS("Exclusive CPU allocation skipped, pod requested non-integral CPUs", "pod", klog.KObj(pod), "containerName", container.Name, "cpu", cpuValue)

pkg/kubelet/cm/memorymanager/policy_static.go

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -471,23 +471,7 @@ func (p *staticPolicy) GetTopologyHints(ctx context.Context, s state.State, pod
471471

472472
func getRequestedResources(pod *v1.Pod, container *v1.Container) (map[v1.ResourceName]uint64, error) {
473473
requestedResources := map[v1.ResourceName]uint64{}
474-
resources := container.Resources.Requests
475-
// In-place pod resize feature makes Container.Resources field mutable for CPU & memory.
476-
// AllocatedResources holds the value of Container.Resources.Requests when the pod was admitted.
477-
// We should return this value because this is what kubelet agreed to allocate for the container
478-
// and the value configured with runtime.
479-
if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) {
480-
containerStatuses := pod.Status.ContainerStatuses
481-
if podutil.IsRestartableInitContainer(container) {
482-
if len(pod.Status.InitContainerStatuses) != 0 {
483-
containerStatuses = append(containerStatuses, pod.Status.InitContainerStatuses...)
484-
}
485-
}
486-
if cs, ok := podutil.GetContainerStatus(containerStatuses, container.Name); ok {
487-
resources = cs.AllocatedResources
488-
}
489-
}
490-
for resourceName, quantity := range resources {
474+
for resourceName, quantity := range container.Resources.Requests {
491475
if resourceName != v1.ResourceMemory && !corehelper.IsHugePageResourceName(resourceName) {
492476
continue
493477
}

0 commit comments

Comments
 (0)