@@ -34,14 +34,12 @@ import (
34
34
utilerrors "k8s.io/apimachinery/pkg/util/errors"
35
35
"k8s.io/apiserver/pkg/admission"
36
36
genericadmissioninitailizer "k8s.io/apiserver/pkg/admission/initializer"
37
- "k8s.io/apiserver/pkg/util/feature"
38
37
"k8s.io/client-go/informers"
39
38
"k8s.io/client-go/kubernetes"
40
39
corev1listers "k8s.io/client-go/listers/core/v1"
41
40
"k8s.io/utils/lru"
42
41
43
42
api "k8s.io/kubernetes/pkg/apis/core"
44
- "k8s.io/kubernetes/pkg/features"
45
43
)
46
44
47
45
const (
@@ -523,11 +521,8 @@ func PodValidateLimitFunc(limitRange *corev1.LimitRange, pod *api.Pod) error {
523
521
524
522
// enforce pod limits on init containers
525
523
if limitType == corev1 .LimitTypePod {
526
- opts := podResourcesOptions {
527
- InPlacePodVerticalScalingEnabled : feature .DefaultFeatureGate .Enabled (features .InPlacePodVerticalScaling ),
528
- }
529
- podRequests := podRequests (pod , opts )
530
- podLimits := podLimits (pod , opts )
524
+ podRequests := podRequests (pod )
525
+ podLimits := podLimits (pod )
531
526
for k , v := range limit .Min {
532
527
if err := minConstraint (string (limitType ), string (k ), v , podRequests , podLimits ); err != nil {
533
528
errs = append (errs , err )
@@ -548,39 +543,15 @@ func PodValidateLimitFunc(limitRange *corev1.LimitRange, pod *api.Pod) error {
548
543
return utilerrors .NewAggregate (errs )
549
544
}
550
545
551
- type podResourcesOptions struct {
552
- // InPlacePodVerticalScalingEnabled indicates that the in-place pod vertical scaling feature gate is enabled.
553
- InPlacePodVerticalScalingEnabled bool
554
- }
555
-
556
546
// podRequests is a simplified version of pkg/api/v1/resource/PodRequests that operates against the core version of
557
547
// pod. Any changes to that calculation should be reflected here.
558
548
// TODO: Maybe we can consider doing a partial conversion of the pod to a v1
559
549
// type and then using the pkg/api/v1/resource/PodRequests.
560
- func podRequests (pod * api.Pod , opts podResourcesOptions ) api.ResourceList {
550
+ func podRequests (pod * api.Pod ) api.ResourceList {
561
551
reqs := api.ResourceList {}
562
552
563
- var containerStatuses map [string ]* api.ContainerStatus
564
- if opts .InPlacePodVerticalScalingEnabled {
565
- containerStatuses = map [string ]* api.ContainerStatus {}
566
- for i := range pod .Status .ContainerStatuses {
567
- containerStatuses [pod .Status .ContainerStatuses [i ].Name ] = & pod .Status .ContainerStatuses [i ]
568
- }
569
- }
570
-
571
553
for _ , container := range pod .Spec .Containers {
572
554
containerReqs := container .Resources .Requests
573
- if opts .InPlacePodVerticalScalingEnabled {
574
- cs , found := containerStatuses [container .Name ]
575
- if found {
576
- if pod .Status .Resize == api .PodResizeStatusInfeasible {
577
- containerReqs = cs .AllocatedResources
578
- } else {
579
- containerReqs = max (container .Resources .Requests , cs .AllocatedResources )
580
- }
581
- }
582
- }
583
-
584
555
addResourceList (reqs , containerReqs )
585
556
}
586
557
@@ -616,7 +587,7 @@ func podRequests(pod *api.Pod, opts podResourcesOptions) api.ResourceList {
616
587
// pod. Any changes to that calculation should be reflected here.
617
588
// TODO: Maybe we can consider doing a partial conversion of the pod to a v1
618
589
// type and then using the pkg/api/v1/resource/PodLimits.
619
- func podLimits (pod * api.Pod , opts podResourcesOptions ) api.ResourceList {
590
+ func podLimits (pod * api.Pod ) api.ResourceList {
620
591
limits := api.ResourceList {}
621
592
622
593
for _ , container := range pod .Spec .Containers {
0 commit comments