From acd696266e6a6b4d6205eeb83fd22ab3ee47c7a4 Mon Sep 17 00:00:00 2001 From: Paco Xu Date: Tue, 15 Mar 2022 14:50:27 +0800 Subject: [PATCH] mark PodOverhead to GA in v1.24; remove in v1.26 --- api/openapi-spec/swagger.json | 6 +-- api/openapi-spec/v3/api__v1_openapi.json | 2 +- .../v3/apis__apps__v1_openapi.json | 2 +- .../v3/apis__batch__v1_openapi.json | 2 +- .../v3/apis__batch__v1beta1_openapi.json | 2 +- .../v3/apis__node.k8s.io__v1_openapi.json | 2 +- .../apis__node.k8s.io__v1beta1_openapi.json | 2 +- pkg/api/pod/util.go | 16 -------- pkg/api/v1/resource/helpers.go | 4 +- pkg/apis/core/types.go | 1 - pkg/apis/node/types.go | 2 - pkg/features/kube_features.go | 3 +- pkg/generated/openapi/zz_generated.openapi.go | 8 ++-- .../kuberuntime/kuberuntime_sandbox_linux.go | 4 +- pkg/quota/v1/evaluator/core/pods.go | 9 ++--- pkg/quota/v1/evaluator/core/pods_test.go | 40 ++----------------- pkg/registry/node/runtimeclass/strategy.go | 8 ---- pkg/scheduler/eventhandlers.go | 4 +- pkg/scheduler/eventhandlers_test.go | 4 -- .../framework/plugins/feature/feature.go | 1 - .../noderesources/balanced_allocation.go | 1 - .../noderesources/balanced_allocation_test.go | 2 +- .../framework/plugins/noderesources/fit.go | 15 +++---- .../plugins/noderesources/fit_test.go | 12 +++--- .../noderesources/least_allocated_test.go | 2 +- .../noderesources/most_allocated_test.go | 2 +- .../requested_to_capacity_ratio_test.go | 6 +-- .../noderesources/resource_allocation.go | 4 +- pkg/scheduler/framework/plugins/registry.go | 1 - pkg/scheduler/framework/types.go | 2 +- .../pkg/admission/runtimeclass/admission.go | 26 ++---------- .../admission/runtimeclass/admission_test.go | 30 +++----------- .../src/k8s.io/api/core/v1/generated.proto | 1 - staging/src/k8s.io/api/core/v1/types.go | 1 - .../core/v1/types_swagger_doc_generated.go | 2 +- .../src/k8s.io/api/node/v1/generated.proto | 2 - staging/src/k8s.io/api/node/v1/types.go | 2 - .../node/v1/types_swagger_doc_generated.go | 2 +- .../k8s.io/api/node/v1alpha1/generated.proto | 1 - staging/src/k8s.io/api/node/v1alpha1/types.go | 1 - .../v1alpha1/types_swagger_doc_generated.go | 2 +- .../k8s.io/api/node/v1beta1/generated.proto | 1 - staging/src/k8s.io/api/node/v1beta1/types.go | 1 - .../v1beta1/types_swagger_doc_generated.go | 2 +- 44 files changed, 59 insertions(+), 184 deletions(-) diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index 337ff9b09d9c..8f1b2554e86a 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -8663,7 +8663,7 @@ "additionalProperties": { "$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity" }, - "description": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. This field will be autopopulated at admission time by the RuntimeClass admission controller. If the RuntimeClass admission controller is enabled, overhead must not be set in Pod create requests. The RuntimeClass admission controller will reject Pod create requests which have the overhead already set. If RuntimeClass is configured and selected in the PodSpec, Overhead will be set to the value defined in the corresponding RuntimeClass, otherwise it will remain unset and treated as zero. More info: https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md This field is beta-level as of Kubernetes v1.18, and is only honored by servers that enable the PodOverhead feature.", + "description": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. This field will be autopopulated at admission time by the RuntimeClass admission controller. If the RuntimeClass admission controller is enabled, overhead must not be set in Pod create requests. The RuntimeClass admission controller will reject Pod create requests which have the overhead already set. If RuntimeClass is configured and selected in the PodSpec, Overhead will be set to the value defined in the corresponding RuntimeClass, otherwise it will remain unset and treated as zero. More info: https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md", "type": "object" }, "preemptionPolicy": { @@ -13194,7 +13194,7 @@ }, "overhead": { "$ref": "#/definitions/io.k8s.api.node.v1.Overhead", - "description": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see\n https://kubernetes.io/docs/concepts/scheduling-eviction/pod-overhead/\nThis field is in beta starting v1.18 and is only honored by servers that enable the PodOverhead feature." + "description": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see\n https://kubernetes.io/docs/concepts/scheduling-eviction/pod-overhead/" }, "scheduling": { "$ref": "#/definitions/io.k8s.api.node.v1.Scheduling", @@ -13304,7 +13304,7 @@ }, "overhead": { "$ref": "#/definitions/io.k8s.api.node.v1beta1.Overhead", - "description": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md This field is beta-level as of Kubernetes v1.18, and is only honored by servers that enable the PodOverhead feature." + "description": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md" }, "scheduling": { "$ref": "#/definitions/io.k8s.api.node.v1beta1.Scheduling", diff --git a/api/openapi-spec/v3/api__v1_openapi.json b/api/openapi-spec/v3/api__v1_openapi.json index b8b9725e99ab..4b1612338d23 100644 --- a/api/openapi-spec/v3/api__v1_openapi.json +++ b/api/openapi-spec/v3/api__v1_openapi.json @@ -4305,7 +4305,7 @@ "$ref": "#/components/schemas/io.k8s.apimachinery.pkg.api.resource.Quantity", "default": {} }, - "description": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. This field will be autopopulated at admission time by the RuntimeClass admission controller. If the RuntimeClass admission controller is enabled, overhead must not be set in Pod create requests. The RuntimeClass admission controller will reject Pod create requests which have the overhead already set. If RuntimeClass is configured and selected in the PodSpec, Overhead will be set to the value defined in the corresponding RuntimeClass, otherwise it will remain unset and treated as zero. More info: https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md This field is beta-level as of Kubernetes v1.18, and is only honored by servers that enable the PodOverhead feature.", + "description": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. This field will be autopopulated at admission time by the RuntimeClass admission controller. If the RuntimeClass admission controller is enabled, overhead must not be set in Pod create requests. The RuntimeClass admission controller will reject Pod create requests which have the overhead already set. If RuntimeClass is configured and selected in the PodSpec, Overhead will be set to the value defined in the corresponding RuntimeClass, otherwise it will remain unset and treated as zero. More info: https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md", "type": "object" }, "preemptionPolicy": { diff --git a/api/openapi-spec/v3/apis__apps__v1_openapi.json b/api/openapi-spec/v3/apis__apps__v1_openapi.json index 18b397d75703..191c925b2757 100644 --- a/api/openapi-spec/v3/apis__apps__v1_openapi.json +++ b/api/openapi-spec/v3/apis__apps__v1_openapi.json @@ -2995,7 +2995,7 @@ "$ref": "#/components/schemas/io.k8s.apimachinery.pkg.api.resource.Quantity", "default": {} }, - "description": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. This field will be autopopulated at admission time by the RuntimeClass admission controller. If the RuntimeClass admission controller is enabled, overhead must not be set in Pod create requests. The RuntimeClass admission controller will reject Pod create requests which have the overhead already set. If RuntimeClass is configured and selected in the PodSpec, Overhead will be set to the value defined in the corresponding RuntimeClass, otherwise it will remain unset and treated as zero. More info: https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md This field is beta-level as of Kubernetes v1.18, and is only honored by servers that enable the PodOverhead feature.", + "description": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. This field will be autopopulated at admission time by the RuntimeClass admission controller. If the RuntimeClass admission controller is enabled, overhead must not be set in Pod create requests. The RuntimeClass admission controller will reject Pod create requests which have the overhead already set. If RuntimeClass is configured and selected in the PodSpec, Overhead will be set to the value defined in the corresponding RuntimeClass, otherwise it will remain unset and treated as zero. More info: https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md", "type": "object" }, "preemptionPolicy": { diff --git a/api/openapi-spec/v3/apis__batch__v1_openapi.json b/api/openapi-spec/v3/apis__batch__v1_openapi.json index 1d30c68ce9e6..22c481ea6d0d 100644 --- a/api/openapi-spec/v3/apis__batch__v1_openapi.json +++ b/api/openapi-spec/v3/apis__batch__v1_openapi.json @@ -2221,7 +2221,7 @@ "$ref": "#/components/schemas/io.k8s.apimachinery.pkg.api.resource.Quantity", "default": {} }, - "description": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. This field will be autopopulated at admission time by the RuntimeClass admission controller. If the RuntimeClass admission controller is enabled, overhead must not be set in Pod create requests. The RuntimeClass admission controller will reject Pod create requests which have the overhead already set. If RuntimeClass is configured and selected in the PodSpec, Overhead will be set to the value defined in the corresponding RuntimeClass, otherwise it will remain unset and treated as zero. More info: https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md This field is beta-level as of Kubernetes v1.18, and is only honored by servers that enable the PodOverhead feature.", + "description": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. This field will be autopopulated at admission time by the RuntimeClass admission controller. If the RuntimeClass admission controller is enabled, overhead must not be set in Pod create requests. The RuntimeClass admission controller will reject Pod create requests which have the overhead already set. If RuntimeClass is configured and selected in the PodSpec, Overhead will be set to the value defined in the corresponding RuntimeClass, otherwise it will remain unset and treated as zero. More info: https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md", "type": "object" }, "preemptionPolicy": { diff --git a/api/openapi-spec/v3/apis__batch__v1beta1_openapi.json b/api/openapi-spec/v3/apis__batch__v1beta1_openapi.json index 294ecb2a171c..ff239d9c76c5 100644 --- a/api/openapi-spec/v3/apis__batch__v1beta1_openapi.json +++ b/api/openapi-spec/v3/apis__batch__v1beta1_openapi.json @@ -2023,7 +2023,7 @@ "$ref": "#/components/schemas/io.k8s.apimachinery.pkg.api.resource.Quantity", "default": {} }, - "description": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. This field will be autopopulated at admission time by the RuntimeClass admission controller. If the RuntimeClass admission controller is enabled, overhead must not be set in Pod create requests. The RuntimeClass admission controller will reject Pod create requests which have the overhead already set. If RuntimeClass is configured and selected in the PodSpec, Overhead will be set to the value defined in the corresponding RuntimeClass, otherwise it will remain unset and treated as zero. More info: https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md This field is beta-level as of Kubernetes v1.18, and is only honored by servers that enable the PodOverhead feature.", + "description": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. This field will be autopopulated at admission time by the RuntimeClass admission controller. If the RuntimeClass admission controller is enabled, overhead must not be set in Pod create requests. The RuntimeClass admission controller will reject Pod create requests which have the overhead already set. If RuntimeClass is configured and selected in the PodSpec, Overhead will be set to the value defined in the corresponding RuntimeClass, otherwise it will remain unset and treated as zero. More info: https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md", "type": "object" }, "preemptionPolicy": { diff --git a/api/openapi-spec/v3/apis__node.k8s.io__v1_openapi.json b/api/openapi-spec/v3/apis__node.k8s.io__v1_openapi.json index 106c432211ad..0c47843dad2d 100644 --- a/api/openapi-spec/v3/apis__node.k8s.io__v1_openapi.json +++ b/api/openapi-spec/v3/apis__node.k8s.io__v1_openapi.json @@ -74,7 +74,7 @@ }, "overhead": { "$ref": "#/components/schemas/io.k8s.api.node.v1.Overhead", - "description": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see\n https://kubernetes.io/docs/concepts/scheduling-eviction/pod-overhead/\nThis field is in beta starting v1.18 and is only honored by servers that enable the PodOverhead feature." + "description": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see\n https://kubernetes.io/docs/concepts/scheduling-eviction/pod-overhead/" }, "scheduling": { "$ref": "#/components/schemas/io.k8s.api.node.v1.Scheduling", diff --git a/api/openapi-spec/v3/apis__node.k8s.io__v1beta1_openapi.json b/api/openapi-spec/v3/apis__node.k8s.io__v1beta1_openapi.json index 71a3421231a3..580471194c14 100644 --- a/api/openapi-spec/v3/apis__node.k8s.io__v1beta1_openapi.json +++ b/api/openapi-spec/v3/apis__node.k8s.io__v1beta1_openapi.json @@ -74,7 +74,7 @@ }, "overhead": { "$ref": "#/components/schemas/io.k8s.api.node.v1beta1.Overhead", - "description": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md This field is beta-level as of Kubernetes v1.18, and is only honored by servers that enable the PodOverhead feature." + "description": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md" }, "scheduling": { "$ref": "#/components/schemas/io.k8s.api.node.v1beta1.Scheduling", diff --git a/pkg/api/pod/util.go b/pkg/api/pod/util.go index 85abdc1bc74f..680433975436 100644 --- a/pkg/api/pod/util.go +++ b/pkg/api/pod/util.go @@ -571,11 +571,6 @@ func dropDisabledFields( }) } - if !utilfeature.DefaultFeatureGate.Enabled(features.PodOverhead) && !overheadInUse(oldPodSpec) { - // Set Overhead to nil only if the feature is disabled and it is not used - podSpec.Overhead = nil - } - dropDisabledProcMountField(podSpec, oldPodSpec) dropDisabledCSIVolumeSourceAlphaFields(podSpec, oldPodSpec) @@ -659,17 +654,6 @@ func ephemeralContainersInUse(podSpec *api.PodSpec) bool { return len(podSpec.EphemeralContainers) > 0 } -// overheadInUse returns true if the pod spec is non-nil and has Overhead set -func overheadInUse(podSpec *api.PodSpec) bool { - if podSpec == nil { - return false - } - if podSpec.Overhead != nil { - return true - } - return false -} - // procMountInUse returns true if the pod spec is non-nil and has a SecurityContext's ProcMount field set to a non-default value func procMountInUse(podSpec *api.PodSpec) bool { if podSpec == nil { diff --git a/pkg/api/v1/resource/helpers.go b/pkg/api/v1/resource/helpers.go index 49a107c10d2f..707cfc2242a2 100644 --- a/pkg/api/v1/resource/helpers.go +++ b/pkg/api/v1/resource/helpers.go @@ -71,7 +71,7 @@ func PodRequestsAndLimitsReuse(pod *v1.Pod, reuseReqs, reuseLimits v1.ResourceLi // if PodOverhead feature is supported, add overhead for running a pod // to the sum of requests and to non-zero limits: - if pod.Spec.Overhead != nil && utilfeature.DefaultFeatureGate.Enabled(features.PodOverhead) { + if pod.Spec.Overhead != nil { addResourceList(reqs, pod.Spec.Overhead) for name, quantity := range pod.Spec.Overhead { @@ -152,7 +152,7 @@ func GetResourceRequestQuantity(pod *v1.Pod, resourceName v1.ResourceName) resou // if PodOverhead feature is supported, add overhead for running a pod // to the total requests if the resource total is non-zero - if pod.Spec.Overhead != nil && utilfeature.DefaultFeatureGate.Enabled(features.PodOverhead) { + if pod.Spec.Overhead != nil { if podOverhead, ok := pod.Spec.Overhead[resourceName]; ok && !requestQuantity.IsZero() { requestQuantity.Add(podOverhead) } diff --git a/pkg/apis/core/types.go b/pkg/apis/core/types.go index 65b3d1d55cf7..e28f7bc6b5ff 100644 --- a/pkg/apis/core/types.go +++ b/pkg/apis/core/types.go @@ -2944,7 +2944,6 @@ type PodSpec struct { // set. If RuntimeClass is configured and selected in the PodSpec, Overhead will be set to the value // defined in the corresponding RuntimeClass, otherwise it will remain unset and treated as zero. // More info: https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead - // This field is beta-level as of Kubernetes v1.18, and is only honored by servers that enable the PodOverhead feature. // +optional Overhead ResourceList // EnableServiceLinks indicates whether information about services should be injected into pod's diff --git a/pkg/apis/node/types.go b/pkg/apis/node/types.go index 908469449aca..baee7c16423b 100644 --- a/pkg/apis/node/types.go +++ b/pkg/apis/node/types.go @@ -50,8 +50,6 @@ type RuntimeClass struct { // Overhead represents the resource overhead associated with running a pod for a // given RuntimeClass. For more details, see // https://git.k8s.io/enhancements/keps/sig-network/580-pod-readiness-gates - // This field is beta-level as of Kubernetes v1.18, and is only honored by servers - // that enable the PodOverhead feature. // +optional Overhead *Overhead diff --git a/pkg/features/kube_features.go b/pkg/features/kube_features.go index 9d87a9e1cdbb..dda53965d2c1 100644 --- a/pkg/features/kube_features.go +++ b/pkg/features/kube_features.go @@ -391,6 +391,7 @@ const ( // owner: @egernst // alpha: v1.16 // beta: v1.18 + // ga: v1.24 // // Enables PodOverhead, for accounting pod overheads which are specific to a given RuntimeClass PodOverhead featuregate.Feature = "PodOverhead" @@ -893,7 +894,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS KubeletPodResources: {Default: true, PreRelease: featuregate.Beta}, LocalStorageCapacityIsolationFSQuotaMonitoring: {Default: false, PreRelease: featuregate.Alpha}, NonPreemptingPriority: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.25 - PodOverhead: {Default: true, PreRelease: featuregate.Beta}, + PodOverhead: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.26 IPv6DualStack: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.25 EndpointSlice: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.25 EndpointSliceProxying: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.25 diff --git a/pkg/generated/openapi/zz_generated.openapi.go b/pkg/generated/openapi/zz_generated.openapi.go index a45aca1f7539..6e0ab547cb0d 100644 --- a/pkg/generated/openapi/zz_generated.openapi.go +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -22082,7 +22082,7 @@ func schema_k8sio_api_core_v1_PodSpec(ref common.ReferenceCallback) common.OpenA }, "overhead": { SchemaProps: spec.SchemaProps{ - Description: "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. This field will be autopopulated at admission time by the RuntimeClass admission controller. If the RuntimeClass admission controller is enabled, overhead must not be set in Pod create requests. The RuntimeClass admission controller will reject Pod create requests which have the overhead already set. If RuntimeClass is configured and selected in the PodSpec, Overhead will be set to the value defined in the corresponding RuntimeClass, otherwise it will remain unset and treated as zero. More info: https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md This field is beta-level as of Kubernetes v1.18, and is only honored by servers that enable the PodOverhead feature.", + Description: "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. This field will be autopopulated at admission time by the RuntimeClass admission controller. If the RuntimeClass admission controller is enabled, overhead must not be set in Pod create requests. The RuntimeClass admission controller will reject Pod create requests which have the overhead already set. If RuntimeClass is configured and selected in the PodSpec, Overhead will be set to the value defined in the corresponding RuntimeClass, otherwise it will remain unset and treated as zero. More info: https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md", Type: []string{"object"}, AdditionalProperties: &spec.SchemaOrBool{ Allows: true, @@ -34565,7 +34565,7 @@ func schema_k8sio_api_node_v1_RuntimeClass(ref common.ReferenceCallback) common. }, "overhead": { SchemaProps: spec.SchemaProps{ - Description: "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see\n https://kubernetes.io/docs/concepts/scheduling-eviction/pod-overhead/\nThis field is in beta starting v1.18 and is only honored by servers that enable the PodOverhead feature.", + Description: "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see\n https://kubernetes.io/docs/concepts/scheduling-eviction/pod-overhead/", Ref: ref("k8s.io/api/node/v1.Overhead"), }, }, @@ -34832,7 +34832,7 @@ func schema_k8sio_api_node_v1alpha1_RuntimeClassSpec(ref common.ReferenceCallbac }, "overhead": { SchemaProps: spec.SchemaProps{ - Description: "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md This field is beta-level as of Kubernetes v1.18, and is only honored by servers that enable the PodOverhead feature.", + Description: "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md", Ref: ref("k8s.io/api/node/v1alpha1.Overhead"), }, }, @@ -34974,7 +34974,7 @@ func schema_k8sio_api_node_v1beta1_RuntimeClass(ref common.ReferenceCallback) co }, "overhead": { SchemaProps: spec.SchemaProps{ - Description: "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md This field is beta-level as of Kubernetes v1.18, and is only honored by servers that enable the PodOverhead feature.", + Description: "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md", Ref: ref("k8s.io/api/node/v1beta1.Overhead"), }, }, diff --git a/pkg/kubelet/kuberuntime/kuberuntime_sandbox_linux.go b/pkg/kubelet/kuberuntime/kuberuntime_sandbox_linux.go index eb2e56ee90f4..646ee7f23cce 100644 --- a/pkg/kubelet/kuberuntime/kuberuntime_sandbox_linux.go +++ b/pkg/kubelet/kuberuntime/kuberuntime_sandbox_linux.go @@ -21,15 +21,13 @@ package kuberuntime import ( v1 "k8s.io/api/core/v1" - utilfeature "k8s.io/apiserver/pkg/util/feature" runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1" resourcehelper "k8s.io/kubernetes/pkg/api/v1/resource" - "k8s.io/kubernetes/pkg/features" ) func (m *kubeGenericRuntimeManager) convertOverheadToLinuxResources(pod *v1.Pod) *runtimeapi.LinuxContainerResources { resources := &runtimeapi.LinuxContainerResources{} - if pod.Spec.Overhead != nil && utilfeature.DefaultFeatureGate.Enabled(features.PodOverhead) { + if pod.Spec.Overhead != nil { cpu := pod.Spec.Overhead.Cpu() memory := pod.Spec.Overhead.Memory() diff --git a/pkg/quota/v1/evaluator/core/pods.go b/pkg/quota/v1/evaluator/core/pods.go index fd7c47add43b..cd299b7b1578 100644 --- a/pkg/quota/v1/evaluator/core/pods.go +++ b/pkg/quota/v1/evaluator/core/pods.go @@ -30,12 +30,10 @@ import ( "k8s.io/apiserver/pkg/admission" quota "k8s.io/apiserver/pkg/quota/v1" "k8s.io/apiserver/pkg/quota/v1/generic" - "k8s.io/apiserver/pkg/util/feature" api "k8s.io/kubernetes/pkg/apis/core" k8s_api_v1 "k8s.io/kubernetes/pkg/apis/core/v1" "k8s.io/kubernetes/pkg/apis/core/v1/helper" "k8s.io/kubernetes/pkg/apis/core/v1/helper/qos" - "k8s.io/kubernetes/pkg/features" "k8s.io/utils/clock" ) @@ -369,10 +367,9 @@ func PodUsageFunc(obj runtime.Object, clock clock.Clock) (corev1.ResourceList, e limits = quota.Max(limits, pod.Spec.InitContainers[i].Resources.Limits) } - if feature.DefaultFeatureGate.Enabled(features.PodOverhead) { - requests = quota.Add(requests, pod.Spec.Overhead) - limits = quota.Add(limits, pod.Spec.Overhead) - } + requests = quota.Add(requests, pod.Spec.Overhead) + limits = quota.Add(limits, pod.Spec.Overhead) + result = quota.Add(result, podComputeUsageHelper(requests, limits)) return result, nil } diff --git a/pkg/quota/v1/evaluator/core/pods_test.go b/pkg/quota/v1/evaluator/core/pods_test.go index 7c6113b7e3b1..d74f7392adb6 100644 --- a/pkg/quota/v1/evaluator/core/pods_test.go +++ b/pkg/quota/v1/evaluator/core/pods_test.go @@ -27,10 +27,7 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" quota "k8s.io/apiserver/pkg/quota/v1" "k8s.io/apiserver/pkg/quota/v1/generic" - "k8s.io/apiserver/pkg/util/feature" - featuregatetesting "k8s.io/component-base/featuregate/testing" api "k8s.io/kubernetes/pkg/apis/core" - "k8s.io/kubernetes/pkg/features" "k8s.io/kubernetes/pkg/util/node" "k8s.io/utils/clock" testingclock "k8s.io/utils/clock/testing" @@ -154,9 +151,8 @@ func TestPodEvaluatorUsage(t *testing.T) { deletionTimestampNotPastGracePeriod := metav1.NewTime(fakeClock.Now()) testCases := map[string]struct { - pod *api.Pod - usage corev1.ResourceList - podOverheadEnabled bool + pod *api.Pod + usage corev1.ResourceList }{ "init container CPU": { pod: &api.Pod{ @@ -525,41 +521,11 @@ func TestPodEvaluatorUsage(t *testing.T) { corev1.ResourceCPU: resource.MustParse("2"), generic.ObjectCountQuotaResourceNameFor(schema.GroupResource{Resource: "pods"}): resource.MustParse("1"), }, - podOverheadEnabled: true, - }, - "do not count pod overhead as usage with pod overhead disabled": { - pod: &api.Pod{ - Spec: api.PodSpec{ - Overhead: api.ResourceList{ - api.ResourceCPU: resource.MustParse("1"), - }, - Containers: []api.Container{ - { - Resources: api.ResourceRequirements{ - Requests: api.ResourceList{ - api.ResourceCPU: resource.MustParse("1"), - }, - Limits: api.ResourceList{ - api.ResourceCPU: resource.MustParse("2"), - }, - }, - }, - }, - }, - }, - usage: corev1.ResourceList{ - corev1.ResourceRequestsCPU: resource.MustParse("1"), - corev1.ResourceLimitsCPU: resource.MustParse("2"), - corev1.ResourcePods: resource.MustParse("1"), - corev1.ResourceCPU: resource.MustParse("1"), - generic.ObjectCountQuotaResourceNameFor(schema.GroupResource{Resource: "pods"}): resource.MustParse("1"), - }, - podOverheadEnabled: false, }, } + t.Parallel() for testName, testCase := range testCases { t.Run(testName, func(t *testing.T) { - defer featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.PodOverhead, testCase.podOverheadEnabled)() actual, err := evaluator.Usage(testCase.pod) if err != nil { t.Error(err) diff --git a/pkg/registry/node/runtimeclass/strategy.go b/pkg/registry/node/runtimeclass/strategy.go index b7c2b57de2a0..4d0a80514462 100644 --- a/pkg/registry/node/runtimeclass/strategy.go +++ b/pkg/registry/node/runtimeclass/strategy.go @@ -23,11 +23,9 @@ import ( "k8s.io/apimachinery/pkg/util/validation/field" "k8s.io/apiserver/pkg/registry/rest" "k8s.io/apiserver/pkg/storage/names" - utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/apis/node" "k8s.io/kubernetes/pkg/apis/node/validation" - "k8s.io/kubernetes/pkg/features" ) // strategy implements verification logic for RuntimeClass. @@ -58,12 +56,6 @@ func (strategy) AllowCreateOnUpdate() bool { // PrepareForCreate clears fields that are not allowed to be set by end users // on creation. func (strategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { - rc := obj.(*node.RuntimeClass) - - if !utilfeature.DefaultFeatureGate.Enabled(features.PodOverhead) && rc != nil { - // Set Overhead to nil only if the feature is disabled and it is not used - rc.Overhead = nil - } } // PrepareForUpdate clears fields that are not allowed to be set by end users on update. diff --git a/pkg/scheduler/eventhandlers.go b/pkg/scheduler/eventhandlers.go index 96ae9536af57..42b5755cfc2c 100644 --- a/pkg/scheduler/eventhandlers.go +++ b/pkg/scheduler/eventhandlers.go @@ -25,14 +25,12 @@ import ( storagev1 "k8s.io/api/storage/v1" "k8s.io/apimachinery/pkg/runtime/schema" utilruntime "k8s.io/apimachinery/pkg/util/runtime" - "k8s.io/apiserver/pkg/util/feature" "k8s.io/client-go/dynamic/dynamicinformer" "k8s.io/client-go/informers" "k8s.io/client-go/tools/cache" corev1helpers "k8s.io/component-helpers/scheduling/corev1" corev1nodeaffinity "k8s.io/component-helpers/scheduling/corev1/nodeaffinity" "k8s.io/klog/v2" - "k8s.io/kubernetes/pkg/features" "k8s.io/kubernetes/pkg/scheduler/framework" "k8s.io/kubernetes/pkg/scheduler/framework/plugins/nodeaffinity" "k8s.io/kubernetes/pkg/scheduler/framework/plugins/nodename" @@ -491,7 +489,7 @@ func preCheckForNode(nodeInfo *framework.NodeInfo) queue.PreEnqueueCheck { // returns all failures. func AdmissionCheck(pod *v1.Pod, nodeInfo *framework.NodeInfo, includeAllFailures bool) []AdmissionResult { var admissionResults []AdmissionResult - insufficientResources := noderesources.Fits(pod, nodeInfo, feature.DefaultFeatureGate.Enabled(features.PodOverhead)) + insufficientResources := noderesources.Fits(pod, nodeInfo) if len(insufficientResources) != 0 { for i := range insufficientResources { admissionResults = append(admissionResults, AdmissionResult{InsufficientResource: &insufficientResources[i]}) diff --git a/pkg/scheduler/eventhandlers_test.go b/pkg/scheduler/eventhandlers_test.go index 81522ca98924..a5a40c4a43ee 100644 --- a/pkg/scheduler/eventhandlers_test.go +++ b/pkg/scheduler/eventhandlers_test.go @@ -37,9 +37,6 @@ import ( "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes/fake" - "k8s.io/apiserver/pkg/util/feature" - featuregatetesting "k8s.io/component-base/featuregate/testing" - "k8s.io/kubernetes/pkg/features" "k8s.io/kubernetes/pkg/scheduler/framework" "k8s.io/kubernetes/pkg/scheduler/framework/plugins/nodeaffinity" "k8s.io/kubernetes/pkg/scheduler/framework/plugins/nodename" @@ -506,7 +503,6 @@ func TestAdmissionCheck(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - defer featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.PodOverhead, true)() nodeInfo := framework.NewNodeInfo(tt.existingPods...) nodeInfo.SetNode(tt.node) diff --git a/pkg/scheduler/framework/plugins/feature/feature.go b/pkg/scheduler/framework/plugins/feature/feature.go index 38ba8a779061..8ef4be9e6306 100644 --- a/pkg/scheduler/framework/plugins/feature/feature.go +++ b/pkg/scheduler/framework/plugins/feature/feature.go @@ -22,7 +22,6 @@ package feature type Features struct { EnablePodAffinityNamespaceSelector bool EnablePodDisruptionBudget bool - EnablePodOverhead bool EnableReadWriteOncePod bool EnableVolumeCapacityPriority bool EnableCSIStorageCapacity bool diff --git a/pkg/scheduler/framework/plugins/noderesources/balanced_allocation.go b/pkg/scheduler/framework/plugins/noderesources/balanced_allocation.go index c2dcd6d53d4f..4f91937ba542 100644 --- a/pkg/scheduler/framework/plugins/noderesources/balanced_allocation.go +++ b/pkg/scheduler/framework/plugins/noderesources/balanced_allocation.go @@ -91,7 +91,6 @@ func NewBalancedAllocation(baArgs runtime.Object, h framework.Handle, fts featur scorer: balancedResourceScorer, useRequested: true, resourceToWeightMap: resToWeightMap, - enablePodOverhead: fts.EnablePodOverhead, }, }, nil } diff --git a/pkg/scheduler/framework/plugins/noderesources/balanced_allocation_test.go b/pkg/scheduler/framework/plugins/noderesources/balanced_allocation_test.go index 557bd26de5e3..b728cd2d41e7 100644 --- a/pkg/scheduler/framework/plugins/noderesources/balanced_allocation_test.go +++ b/pkg/scheduler/framework/plugins/noderesources/balanced_allocation_test.go @@ -376,7 +376,7 @@ func TestNodeResourcesBalancedAllocation(t *testing.T) { t.Run(test.name, func(t *testing.T) { snapshot := cache.NewSnapshot(test.pods, test.nodes) fh, _ := runtime.NewFramework(nil, nil, runtime.WithSnapshotSharedLister(snapshot)) - p, _ := NewBalancedAllocation(&test.args, fh, feature.Features{EnablePodOverhead: true}) + p, _ := NewBalancedAllocation(&test.args, fh, feature.Features{}) for i := range test.nodes { hostResult, err := p.(framework.ScorePlugin).Score(context.Background(), nil, test.pod, test.nodes[i].Name) if err != nil { diff --git a/pkg/scheduler/framework/plugins/noderesources/fit.go b/pkg/scheduler/framework/plugins/noderesources/fit.go index 90faf7fc8601..1be0f2e512d9 100644 --- a/pkg/scheduler/framework/plugins/noderesources/fit.go +++ b/pkg/scheduler/framework/plugins/noderesources/fit.go @@ -78,7 +78,6 @@ var nodeResourceStrategyTypeMap = map[config.ScoringStrategyType]scorer{ type Fit struct { ignoredResources sets.String ignoredResourceGroups sets.String - enablePodOverhead bool handle framework.Handle resourceAllocationScorer } @@ -126,7 +125,6 @@ func NewFit(plArgs runtime.Object, h framework.Handle, fts feature.Features) (fr return &Fit{ ignoredResources: sets.NewString(args.IgnoredResources...), ignoredResourceGroups: sets.NewString(args.IgnoredResourceGroups...), - enablePodOverhead: fts.EnablePodOverhead, handle: h, resourceAllocationScorer: *scorePlugin(args), }, nil @@ -137,8 +135,7 @@ func NewFit(plArgs runtime.Object, h framework.Handle, fts feature.Features) (fr // the max in each dimension iteratively. In contrast, we sum the resource vectors for // regular containers since they run simultaneously. // -// If Pod Overhead is specified and the feature gate is set, the resources defined for Overhead -// are added to the calculated Resource request sum +// The resources defined for Overhead should be added to the calculated Resource request sum // // Example: // @@ -159,7 +156,7 @@ func NewFit(plArgs runtime.Object, h framework.Handle, fts feature.Features) (fr // Memory: 1G // // Result: CPU: 3, Memory: 3G -func computePodResourceRequest(pod *v1.Pod, enablePodOverhead bool) *preFilterState { +func computePodResourceRequest(pod *v1.Pod) *preFilterState { result := &preFilterState{} for _, container := range pod.Spec.Containers { result.Add(container.Resources.Requests) @@ -171,7 +168,7 @@ func computePodResourceRequest(pod *v1.Pod, enablePodOverhead bool) *preFilterSt } // If Overhead is being utilized, add to the total requests for the pod - if pod.Spec.Overhead != nil && enablePodOverhead { + if pod.Spec.Overhead != nil { result.Add(pod.Spec.Overhead) } return result @@ -179,7 +176,7 @@ func computePodResourceRequest(pod *v1.Pod, enablePodOverhead bool) *preFilterSt // PreFilter invoked at the prefilter extension point. func (f *Fit) PreFilter(ctx context.Context, cycleState *framework.CycleState, pod *v1.Pod) (*framework.PreFilterResult, *framework.Status) { - cycleState.Write(preFilterStateKey, computePodResourceRequest(pod, f.enablePodOverhead)) + cycleState.Write(preFilterStateKey, computePodResourceRequest(pod)) return nil, nil } @@ -248,8 +245,8 @@ type InsufficientResource struct { } // Fits checks if node have enough resources to host the pod. -func Fits(pod *v1.Pod, nodeInfo *framework.NodeInfo, enablePodOverhead bool) []InsufficientResource { - return fitsRequest(computePodResourceRequest(pod, enablePodOverhead), nodeInfo, nil, nil) +func Fits(pod *v1.Pod, nodeInfo *framework.NodeInfo) []InsufficientResource { + return fitsRequest(computePodResourceRequest(pod), nodeInfo, nil, nil) } func fitsRequest(podRequest *preFilterState, nodeInfo *framework.NodeInfo, ignoredExtendedResources, ignoredResourceGroups sets.String) []InsufficientResource { diff --git a/pkg/scheduler/framework/plugins/noderesources/fit_test.go b/pkg/scheduler/framework/plugins/noderesources/fit_test.go index c4918120d8cd..1d5360285add 100644 --- a/pkg/scheduler/framework/plugins/noderesources/fit_test.go +++ b/pkg/scheduler/framework/plugins/noderesources/fit_test.go @@ -472,7 +472,7 @@ func TestEnoughRequests(t *testing.T) { test.args.ScoringStrategy = defaultScoringStrategy } - p, err := NewFit(&test.args, nil, plfeature.Features{EnablePodOverhead: true}) + p, err := NewFit(&test.args, nil, plfeature.Features{}) if err != nil { t.Fatal(err) } @@ -487,7 +487,7 @@ func TestEnoughRequests(t *testing.T) { t.Errorf("status does not match: %v, want: %v", gotStatus, test.wantStatus) } - gotInsufficientResources := fitsRequest(computePodResourceRequest(test.pod, true), test.nodeInfo, p.(*Fit).ignoredResources, p.(*Fit).ignoredResourceGroups) + gotInsufficientResources := fitsRequest(computePodResourceRequest(test.pod), test.nodeInfo, p.(*Fit).ignoredResources, p.(*Fit).ignoredResourceGroups) if !reflect.DeepEqual(gotInsufficientResources, test.wantInsufficientResources) { t.Errorf("insufficient resources do not match: %+v, want: %v", gotInsufficientResources, test.wantInsufficientResources) } @@ -500,7 +500,7 @@ func TestPreFilterDisabled(t *testing.T) { nodeInfo := framework.NewNodeInfo() node := v1.Node{} nodeInfo.SetNode(&node) - p, err := NewFit(&config.NodeResourcesFitArgs{ScoringStrategy: defaultScoringStrategy}, nil, plfeature.Features{EnablePodOverhead: true}) + p, err := NewFit(&config.NodeResourcesFitArgs{ScoringStrategy: defaultScoringStrategy}, nil, plfeature.Features{}) if err != nil { t.Fatal(err) } @@ -550,7 +550,7 @@ func TestNotEnoughRequests(t *testing.T) { node := v1.Node{Status: v1.NodeStatus{Capacity: v1.ResourceList{}, Allocatable: makeAllocatableResources(10, 20, 1, 0, 0, 0)}} test.nodeInfo.SetNode(&node) - p, err := NewFit(&config.NodeResourcesFitArgs{ScoringStrategy: defaultScoringStrategy}, nil, plfeature.Features{EnablePodOverhead: true}) + p, err := NewFit(&config.NodeResourcesFitArgs{ScoringStrategy: defaultScoringStrategy}, nil, plfeature.Features{}) if err != nil { t.Fatal(err) } @@ -622,7 +622,7 @@ func TestStorageRequests(t *testing.T) { node := v1.Node{Status: v1.NodeStatus{Capacity: makeResources(10, 20, 32, 5, 20, 5).Capacity, Allocatable: makeAllocatableResources(10, 20, 32, 5, 20, 5)}} test.nodeInfo.SetNode(&node) - p, err := NewFit(&config.NodeResourcesFitArgs{ScoringStrategy: defaultScoringStrategy}, nil, plfeature.Features{EnablePodOverhead: true}) + p, err := NewFit(&config.NodeResourcesFitArgs{ScoringStrategy: defaultScoringStrategy}, nil, plfeature.Features{}) if err != nil { t.Fatal(err) } @@ -759,7 +759,7 @@ func TestFitScore(t *testing.T) { snapshot := cache.NewSnapshot(test.existingPods, test.nodes) fh, _ := runtime.NewFramework(nil, nil, runtime.WithSnapshotSharedLister(snapshot)) args := test.nodeResourcesFitArgs - p, err := NewFit(&args, fh, plfeature.Features{EnablePodOverhead: true}) + p, err := NewFit(&args, fh, plfeature.Features{}) if err != nil { t.Fatalf("unexpected error: %v", err) } diff --git a/pkg/scheduler/framework/plugins/noderesources/least_allocated_test.go b/pkg/scheduler/framework/plugins/noderesources/least_allocated_test.go index bb1c8fc15485..f6d3391d4f79 100644 --- a/pkg/scheduler/framework/plugins/noderesources/least_allocated_test.go +++ b/pkg/scheduler/framework/plugins/noderesources/least_allocated_test.go @@ -384,7 +384,7 @@ func TestLeastAllocatedScoringStrategy(t *testing.T) { Type: config.LeastAllocated, Resources: test.resources, }, - }, fh, plfeature.Features{EnablePodOverhead: true}) + }, fh, plfeature.Features{}) if diff := cmp.Diff(test.wantErrs.ToAggregate(), err, ignoreBadValueDetail); diff != "" { t.Fatalf("got err (-want,+got):\n%s", diff) diff --git a/pkg/scheduler/framework/plugins/noderesources/most_allocated_test.go b/pkg/scheduler/framework/plugins/noderesources/most_allocated_test.go index e77171d1f170..b5e9b14cdd5b 100644 --- a/pkg/scheduler/framework/plugins/noderesources/most_allocated_test.go +++ b/pkg/scheduler/framework/plugins/noderesources/most_allocated_test.go @@ -340,7 +340,7 @@ func TestMostAllocatedScoringStrategy(t *testing.T) { Type: config.MostAllocated, Resources: test.resources, }, - }, fh, plfeature.Features{EnablePodOverhead: true}) + }, fh, plfeature.Features{}) if diff := cmp.Diff(test.wantErrs.ToAggregate(), err, ignoreBadValueDetail); diff != "" { t.Fatalf("got err (-want,+got):\n%s", diff) diff --git a/pkg/scheduler/framework/plugins/noderesources/requested_to_capacity_ratio_test.go b/pkg/scheduler/framework/plugins/noderesources/requested_to_capacity_ratio_test.go index bb3733560b42..3b0970891c7c 100644 --- a/pkg/scheduler/framework/plugins/noderesources/requested_to_capacity_ratio_test.go +++ b/pkg/scheduler/framework/plugins/noderesources/requested_to_capacity_ratio_test.go @@ -121,7 +121,7 @@ func TestRequestedToCapacityRatioScoringStrategy(t *testing.T) { Shape: shape, }, }, - }, fh, plfeature.Features{EnablePodOverhead: true}) + }, fh, plfeature.Features{}) if diff := cmp.Diff(test.wantErrs.ToAggregate(), err, ignoreBadValueDetail); diff != "" { t.Fatalf("got err (-want,+got):\n%s", diff) @@ -340,7 +340,7 @@ func TestResourceBinPackingSingleExtended(t *testing.T) { }, }, } - p, err := NewFit(&args, fh, feature.Features{EnablePodOverhead: true}) + p, err := NewFit(&args, fh, feature.Features{}) if err != nil { t.Fatalf("unexpected error: %v", err) } @@ -588,7 +588,7 @@ func TestResourceBinPackingMultipleExtended(t *testing.T) { }, } - p, err := NewFit(&args, fh, feature.Features{EnablePodOverhead: true}) + p, err := NewFit(&args, fh, feature.Features{}) if err != nil { t.Fatalf("unexpected error: %v", err) } diff --git a/pkg/scheduler/framework/plugins/noderesources/resource_allocation.go b/pkg/scheduler/framework/plugins/noderesources/resource_allocation.go index 0ce09536cd43..48eadc88ff09 100644 --- a/pkg/scheduler/framework/plugins/noderesources/resource_allocation.go +++ b/pkg/scheduler/framework/plugins/noderesources/resource_allocation.go @@ -38,8 +38,6 @@ type resourceAllocationScorer struct { useRequested bool scorer func(requested, allocable resourceToValueMap) int64 resourceToWeightMap resourceToWeightMap - - enablePodOverhead bool } // resourceToValueMap is keyed with resource name and valued with quantity. @@ -129,7 +127,7 @@ func (r *resourceAllocationScorer) calculatePodResourceRequest(pod *v1.Pod, reso } // If Overhead is being utilized, add to the total requests for the pod - if pod.Spec.Overhead != nil && r.enablePodOverhead { + if pod.Spec.Overhead != nil { if quantity, found := pod.Spec.Overhead[resource]; found { podRequest += quantity.Value() } diff --git a/pkg/scheduler/framework/plugins/registry.go b/pkg/scheduler/framework/plugins/registry.go index 793b6c895b0b..79c7cde807f2 100644 --- a/pkg/scheduler/framework/plugins/registry.go +++ b/pkg/scheduler/framework/plugins/registry.go @@ -46,7 +46,6 @@ import ( func NewInTreeRegistry() runtime.Registry { fts := plfeature.Features{ EnablePodDisruptionBudget: feature.DefaultFeatureGate.Enabled(features.PodDisruptionBudget), - EnablePodOverhead: feature.DefaultFeatureGate.Enabled(features.PodOverhead), EnableReadWriteOncePod: feature.DefaultFeatureGate.Enabled(features.ReadWriteOncePod), EnableVolumeCapacityPriority: feature.DefaultFeatureGate.Enabled(features.VolumeCapacityPriority), EnableCSIStorageCapacity: feature.DefaultFeatureGate.Enabled(features.CSIStorageCapacity), diff --git a/pkg/scheduler/framework/types.go b/pkg/scheduler/framework/types.go index 0cf527bbcf97..0c9dd74c380e 100644 --- a/pkg/scheduler/framework/types.go +++ b/pkg/scheduler/framework/types.go @@ -736,7 +736,7 @@ func calculateResource(pod *v1.Pod) (res Resource, non0CPU int64, non0Mem int64) } // If Overhead is being utilized, add to the total requests for the pod - if pod.Spec.Overhead != nil && utilfeature.DefaultFeatureGate.Enabled(features.PodOverhead) { + if pod.Spec.Overhead != nil { resPtr.Add(pod.Spec.Overhead) if _, found := pod.Spec.Overhead[v1.ResourceCPU]; found { non0CPU += pod.Spec.Overhead.Cpu().MilliValue() diff --git a/plugin/pkg/admission/runtimeclass/admission.go b/plugin/pkg/admission/runtimeclass/admission.go index 29231d8ce181..ed2e8b1343f0 100644 --- a/plugin/pkg/admission/runtimeclass/admission.go +++ b/plugin/pkg/admission/runtimeclass/admission.go @@ -36,11 +36,9 @@ import ( "k8s.io/client-go/kubernetes" nodev1client "k8s.io/client-go/kubernetes/typed/node/v1" nodev1listers "k8s.io/client-go/listers/node/v1" - "k8s.io/component-base/featuregate" api "k8s.io/kubernetes/pkg/apis/core" node "k8s.io/kubernetes/pkg/apis/node" apinodev1 "k8s.io/kubernetes/pkg/apis/node/v1" - "k8s.io/kubernetes/pkg/features" "k8s.io/kubernetes/pkg/util/tolerations" ) @@ -62,9 +60,6 @@ type RuntimeClass struct { *admission.Handler runtimeClassLister nodev1listers.RuntimeClassLister runtimeClassClient nodev1client.RuntimeClassInterface - - inspectedFeatures bool - podOverheadEnabled bool } var _ admission.MutationInterface = &RuntimeClass{} @@ -78,12 +73,6 @@ func (r *RuntimeClass) SetExternalKubeClientSet(client kubernetes.Interface) { r.runtimeClassClient = client.NodeV1().RuntimeClasses() } -// InspectFeatureGates allows setting bools without taking a dep on a global variable -func (r *RuntimeClass) InspectFeatureGates(featureGates featuregate.FeatureGate) { - r.podOverheadEnabled = featureGates.Enabled(features.PodOverhead) - r.inspectedFeatures = true -} - // SetExternalKubeInformerFactory implements the WantsExternalKubeInformerFactory interface. func (r *RuntimeClass) SetExternalKubeInformerFactory(f informers.SharedInformerFactory) { runtimeClassInformer := f.Node().V1().RuntimeClasses() @@ -93,9 +82,6 @@ func (r *RuntimeClass) SetExternalKubeInformerFactory(f informers.SharedInformer // ValidateInitialization implements the WantsExternalKubeInformerFactory interface. func (r *RuntimeClass) ValidateInitialization() error { - if !r.inspectedFeatures { - return fmt.Errorf("InspectFeatureGates was not called") - } if r.runtimeClassLister == nil { return fmt.Errorf("missing RuntimeClass lister") } @@ -116,10 +102,8 @@ func (r *RuntimeClass) Admit(ctx context.Context, attributes admission.Attribute if err != nil { return err } - if r.podOverheadEnabled { - if err := setOverhead(attributes, pod, runtimeClass); err != nil { - return err - } + if err := setOverhead(attributes, pod, runtimeClass); err != nil { + return err } if err := setScheduling(attributes, pod, runtimeClass); err != nil { @@ -140,10 +124,8 @@ func (r *RuntimeClass) Validate(ctx context.Context, attributes admission.Attrib if err != nil { return err } - if r.podOverheadEnabled { - if err := validateOverhead(attributes, pod, runtimeClass); err != nil { - return err - } + if err := validateOverhead(attributes, pod, runtimeClass); err != nil { + return err } return nil diff --git a/plugin/pkg/admission/runtimeclass/admission_test.go b/plugin/pkg/admission/runtimeclass/admission_test.go index 6329e48bd19c..2b345c80c407 100644 --- a/plugin/pkg/admission/runtimeclass/admission_test.go +++ b/plugin/pkg/admission/runtimeclass/admission_test.go @@ -31,10 +31,8 @@ import ( "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/fake" - "k8s.io/component-base/featuregate" "k8s.io/kubernetes/pkg/apis/core" "k8s.io/kubernetes/pkg/controller" - "k8s.io/kubernetes/pkg/features" "github.com/stretchr/testify/assert" ) @@ -321,22 +319,12 @@ func NewObjectInterfacesForTest() admission.ObjectInterfaces { } func newRuntimeClassForTest( - featureInspection bool, addLister bool, listerObject *nodev1.RuntimeClass, addClient bool, clientObject *nodev1.RuntimeClass) *RuntimeClass { runtimeClass := NewRuntimeClass() - if featureInspection { - relevantFeatures := map[featuregate.Feature]featuregate.FeatureSpec{ - features.PodOverhead: {Default: false}, - } - fg := featuregate.NewFeatureGate() - fg.Add(relevantFeatures) - runtimeClass.InspectFeatureGates(fg) - } - if addLister { informerFactory := informers.NewSharedInformerFactory(nil, controller.NoResyncPeriodFunc()) runtimeClass.SetExternalKubeInformerFactory(informerFactory) @@ -367,22 +355,17 @@ func TestValidateInitialization(t *testing.T) { { name: "runtimeClass enabled, success", expectError: false, - runtimeClass: newRuntimeClassForTest(true, true, nil, true, nil), - }, - { - name: "runtimeClass enabled, no feature inspection", - expectError: true, - runtimeClass: newRuntimeClassForTest(false, true, nil, true, nil), + runtimeClass: newRuntimeClassForTest(true, nil, true, nil), }, { name: "runtimeClass enabled, no lister", expectError: true, - runtimeClass: newRuntimeClassForTest(true, false, nil, true, nil), + runtimeClass: newRuntimeClassForTest(false, nil, true, nil), }, { name: "runtimeClass enabled, no client", expectError: true, - runtimeClass: newRuntimeClassForTest(true, true, nil, false, nil), + runtimeClass: newRuntimeClassForTest(true, nil, false, nil), }, } @@ -432,17 +415,17 @@ func TestAdmit(t *testing.T) { { name: "runtimeClass found by lister", expectError: false, - runtimeClass: newRuntimeClassForTest(true, true, rc, true, nil), + runtimeClass: newRuntimeClassForTest(true, rc, true, nil), }, { name: "runtimeClass found by client", expectError: false, - runtimeClass: newRuntimeClassForTest(true, true, nil, true, rc), + runtimeClass: newRuntimeClassForTest(true, nil, true, rc), }, { name: "runtimeClass not found by lister nor client", expectError: true, - runtimeClass: newRuntimeClassForTest(true, true, nil, true, nil), + runtimeClass: newRuntimeClassForTest(true, nil, true, nil), }, } @@ -506,7 +489,6 @@ func TestValidate(t *testing.T) { }, } rt := NewRuntimeClass() - rt.podOverheadEnabled = true o := NewObjectInterfacesForTest() for _, tc := range tests { t.Run(tc.name, func(t *testing.T) { diff --git a/staging/src/k8s.io/api/core/v1/generated.proto b/staging/src/k8s.io/api/core/v1/generated.proto index 37ec3bcf319f..2d7ec87c69e0 100644 --- a/staging/src/k8s.io/api/core/v1/generated.proto +++ b/staging/src/k8s.io/api/core/v1/generated.proto @@ -3670,7 +3670,6 @@ message PodSpec { // set. If RuntimeClass is configured and selected in the PodSpec, Overhead will be set to the value // defined in the corresponding RuntimeClass, otherwise it will remain unset and treated as zero. // More info: https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md - // This field is beta-level as of Kubernetes v1.18, and is only honored by servers that enable the PodOverhead feature. // +optional map overhead = 32; diff --git a/staging/src/k8s.io/api/core/v1/types.go b/staging/src/k8s.io/api/core/v1/types.go index 164a29d38cdc..d2619e55d09f 100644 --- a/staging/src/k8s.io/api/core/v1/types.go +++ b/staging/src/k8s.io/api/core/v1/types.go @@ -3252,7 +3252,6 @@ type PodSpec struct { // set. If RuntimeClass is configured and selected in the PodSpec, Overhead will be set to the value // defined in the corresponding RuntimeClass, otherwise it will remain unset and treated as zero. // More info: https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md - // This field is beta-level as of Kubernetes v1.18, and is only honored by servers that enable the PodOverhead feature. // +optional Overhead ResourceList `json:"overhead,omitempty" protobuf:"bytes,32,opt,name=overhead"` // TopologySpreadConstraints describes how a group of pods ought to spread across topology diff --git a/staging/src/k8s.io/api/core/v1/types_swagger_doc_generated.go b/staging/src/k8s.io/api/core/v1/types_swagger_doc_generated.go index d5e30c7ae80d..434a00a13348 100644 --- a/staging/src/k8s.io/api/core/v1/types_swagger_doc_generated.go +++ b/staging/src/k8s.io/api/core/v1/types_swagger_doc_generated.go @@ -1666,7 +1666,7 @@ var map_PodSpec = map[string]string{ "runtimeClassName": "RuntimeClassName refers to a RuntimeClass object in the node.k8s.io group, which should be used to run this pod. If no RuntimeClass resource matches the named class, the pod will not be run. If unset or empty, the \"legacy\" RuntimeClass will be used, which is an implicit class with an empty definition that uses the default runtime handler. More info: https://git.k8s.io/enhancements/keps/sig-node/585-runtime-class", "enableServiceLinks": "EnableServiceLinks indicates whether information about services should be injected into pod's environment variables, matching the syntax of Docker links. Optional: Defaults to true.", "preemptionPolicy": "PreemptionPolicy is the Policy for preempting pods with lower priority. One of Never, PreemptLowerPriority. Defaults to PreemptLowerPriority if unset.", - "overhead": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. This field will be autopopulated at admission time by the RuntimeClass admission controller. If the RuntimeClass admission controller is enabled, overhead must not be set in Pod create requests. The RuntimeClass admission controller will reject Pod create requests which have the overhead already set. If RuntimeClass is configured and selected in the PodSpec, Overhead will be set to the value defined in the corresponding RuntimeClass, otherwise it will remain unset and treated as zero. More info: https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md This field is beta-level as of Kubernetes v1.18, and is only honored by servers that enable the PodOverhead feature.", + "overhead": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. This field will be autopopulated at admission time by the RuntimeClass admission controller. If the RuntimeClass admission controller is enabled, overhead must not be set in Pod create requests. The RuntimeClass admission controller will reject Pod create requests which have the overhead already set. If RuntimeClass is configured and selected in the PodSpec, Overhead will be set to the value defined in the corresponding RuntimeClass, otherwise it will remain unset and treated as zero. More info: https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md", "topologySpreadConstraints": "TopologySpreadConstraints describes how a group of pods ought to spread across topology domains. Scheduler will schedule pods in a way which abides by the constraints. All topologySpreadConstraints are ANDed.", "setHostnameAsFQDN": "If true the pod's hostname will be configured as the pod's FQDN, rather than the leaf name (the default). In Linux containers, this means setting the FQDN in the hostname field of the kernel (the nodename field of struct utsname). In Windows containers, this means setting the registry value of hostname for the registry key HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters to FQDN. If a pod does not have FQDN, this has no effect. Default to false.", "os": "Specifies the OS of the containers in the pod. Some pod and container fields are restricted if this is set.\n\nIf the OS field is set to linux, the following fields must be unset: -securityContext.windowsOptions\n\nIf the OS field is set to windows, following fields must be unset: - spec.hostPID - spec.hostIPC - spec.securityContext.seLinuxOptions - spec.securityContext.seccompProfile - spec.securityContext.fsGroup - spec.securityContext.fsGroupChangePolicy - spec.securityContext.sysctls - spec.shareProcessNamespace - spec.securityContext.runAsUser - spec.securityContext.runAsGroup - spec.securityContext.supplementalGroups - spec.containers[*].securityContext.seLinuxOptions - spec.containers[*].securityContext.seccompProfile - spec.containers[*].securityContext.capabilities - spec.containers[*].securityContext.readOnlyRootFilesystem - spec.containers[*].securityContext.privileged - spec.containers[*].securityContext.allowPrivilegeEscalation - spec.containers[*].securityContext.procMount - spec.containers[*].securityContext.runAsUser - spec.containers[*].securityContext.runAsGroup This is an alpha field and requires the IdentifyPodOS feature", diff --git a/staging/src/k8s.io/api/node/v1/generated.proto b/staging/src/k8s.io/api/node/v1/generated.proto index a0774b898914..294be85b6248 100644 --- a/staging/src/k8s.io/api/node/v1/generated.proto +++ b/staging/src/k8s.io/api/node/v1/generated.proto @@ -64,8 +64,6 @@ message RuntimeClass { // Overhead represents the resource overhead associated with running a pod for a // given RuntimeClass. For more details, see // https://kubernetes.io/docs/concepts/scheduling-eviction/pod-overhead/ - // This field is in beta starting v1.18 - // and is only honored by servers that enable the PodOverhead feature. // +optional optional Overhead overhead = 3; diff --git a/staging/src/k8s.io/api/node/v1/types.go b/staging/src/k8s.io/api/node/v1/types.go index bfe947e1fcd4..984696d98373 100644 --- a/staging/src/k8s.io/api/node/v1/types.go +++ b/staging/src/k8s.io/api/node/v1/types.go @@ -53,8 +53,6 @@ type RuntimeClass struct { // Overhead represents the resource overhead associated with running a pod for a // given RuntimeClass. For more details, see // https://kubernetes.io/docs/concepts/scheduling-eviction/pod-overhead/ - // This field is in beta starting v1.18 - // and is only honored by servers that enable the PodOverhead feature. // +optional Overhead *Overhead `json:"overhead,omitempty" protobuf:"bytes,3,opt,name=overhead"` diff --git a/staging/src/k8s.io/api/node/v1/types_swagger_doc_generated.go b/staging/src/k8s.io/api/node/v1/types_swagger_doc_generated.go index c68c40e90f59..a9eddc60ea32 100644 --- a/staging/src/k8s.io/api/node/v1/types_swagger_doc_generated.go +++ b/staging/src/k8s.io/api/node/v1/types_swagger_doc_generated.go @@ -40,7 +40,7 @@ var map_RuntimeClass = map[string]string{ "": "RuntimeClass defines a class of container runtime supported in the cluster. The RuntimeClass is used to determine which container runtime is used to run all containers in a pod. RuntimeClasses are manually defined by a user or cluster provisioner, and referenced in the PodSpec. The Kubelet is responsible for resolving the RuntimeClassName reference before running the pod. For more details, see https://kubernetes.io/docs/concepts/containers/runtime-class/", "metadata": "More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", "handler": "Handler specifies the underlying runtime and configuration that the CRI implementation will use to handle pods of this class. The possible values are specific to the node & CRI configuration. It is assumed that all handlers are available on every node, and handlers of the same name are equivalent on every node. For example, a handler called \"runc\" might specify that the runc OCI runtime (using native Linux containers) will be used to run the containers in a pod. The Handler must be lowercase, conform to the DNS Label (RFC 1123) requirements, and is immutable.", - "overhead": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see\n https://kubernetes.io/docs/concepts/scheduling-eviction/pod-overhead/\nThis field is in beta starting v1.18 and is only honored by servers that enable the PodOverhead feature.", + "overhead": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see\n https://kubernetes.io/docs/concepts/scheduling-eviction/pod-overhead/", "scheduling": "Scheduling holds the scheduling constraints to ensure that pods running with this RuntimeClass are scheduled to nodes that support it. If scheduling is nil, this RuntimeClass is assumed to be supported by all nodes.", } diff --git a/staging/src/k8s.io/api/node/v1alpha1/generated.proto b/staging/src/k8s.io/api/node/v1alpha1/generated.proto index fc602e08129f..d46e0ec6aa1a 100644 --- a/staging/src/k8s.io/api/node/v1alpha1/generated.proto +++ b/staging/src/k8s.io/api/node/v1alpha1/generated.proto @@ -85,7 +85,6 @@ message RuntimeClassSpec { // Overhead represents the resource overhead associated with running a pod for a // given RuntimeClass. For more details, see // https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md - // This field is beta-level as of Kubernetes v1.18, and is only honored by servers that enable the PodOverhead feature. // +optional optional Overhead overhead = 2; diff --git a/staging/src/k8s.io/api/node/v1alpha1/types.go b/staging/src/k8s.io/api/node/v1alpha1/types.go index f11bcbb10ad9..588c8e4c0a72 100644 --- a/staging/src/k8s.io/api/node/v1alpha1/types.go +++ b/staging/src/k8s.io/api/node/v1alpha1/types.go @@ -63,7 +63,6 @@ type RuntimeClassSpec struct { // Overhead represents the resource overhead associated with running a pod for a // given RuntimeClass. For more details, see // https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md - // This field is beta-level as of Kubernetes v1.18, and is only honored by servers that enable the PodOverhead feature. // +optional Overhead *Overhead `json:"overhead,omitempty" protobuf:"bytes,2,opt,name=overhead"` diff --git a/staging/src/k8s.io/api/node/v1alpha1/types_swagger_doc_generated.go b/staging/src/k8s.io/api/node/v1alpha1/types_swagger_doc_generated.go index 5a259573c3e1..96413754f050 100644 --- a/staging/src/k8s.io/api/node/v1alpha1/types_swagger_doc_generated.go +++ b/staging/src/k8s.io/api/node/v1alpha1/types_swagger_doc_generated.go @@ -59,7 +59,7 @@ func (RuntimeClassList) SwaggerDoc() map[string]string { var map_RuntimeClassSpec = map[string]string{ "": "RuntimeClassSpec is a specification of a RuntimeClass. It contains parameters that are required to describe the RuntimeClass to the Container Runtime Interface (CRI) implementation, as well as any other components that need to understand how the pod will be run. The RuntimeClassSpec is immutable.", "runtimeHandler": "RuntimeHandler specifies the underlying runtime and configuration that the CRI implementation will use to handle pods of this class. The possible values are specific to the node & CRI configuration. It is assumed that all handlers are available on every node, and handlers of the same name are equivalent on every node. For example, a handler called \"runc\" might specify that the runc OCI runtime (using native Linux containers) will be used to run the containers in a pod. The RuntimeHandler must be lowercase, conform to the DNS Label (RFC 1123) requirements, and is immutable.", - "overhead": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md This field is beta-level as of Kubernetes v1.18, and is only honored by servers that enable the PodOverhead feature.", + "overhead": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md", "scheduling": "Scheduling holds the scheduling constraints to ensure that pods running with this RuntimeClass are scheduled to nodes that support it. If scheduling is nil, this RuntimeClass is assumed to be supported by all nodes.", } diff --git a/staging/src/k8s.io/api/node/v1beta1/generated.proto b/staging/src/k8s.io/api/node/v1beta1/generated.proto index c7e9ee4ac33e..8ffad6973142 100644 --- a/staging/src/k8s.io/api/node/v1beta1/generated.proto +++ b/staging/src/k8s.io/api/node/v1beta1/generated.proto @@ -64,7 +64,6 @@ message RuntimeClass { // Overhead represents the resource overhead associated with running a pod for a // given RuntimeClass. For more details, see // https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md - // This field is beta-level as of Kubernetes v1.18, and is only honored by servers that enable the PodOverhead feature. // +optional optional Overhead overhead = 3; diff --git a/staging/src/k8s.io/api/node/v1beta1/types.go b/staging/src/k8s.io/api/node/v1beta1/types.go index c545abf18b02..b924cb421ad5 100644 --- a/staging/src/k8s.io/api/node/v1beta1/types.go +++ b/staging/src/k8s.io/api/node/v1beta1/types.go @@ -55,7 +55,6 @@ type RuntimeClass struct { // Overhead represents the resource overhead associated with running a pod for a // given RuntimeClass. For more details, see // https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md - // This field is beta-level as of Kubernetes v1.18, and is only honored by servers that enable the PodOverhead feature. // +optional Overhead *Overhead `json:"overhead,omitempty" protobuf:"bytes,3,opt,name=overhead"` diff --git a/staging/src/k8s.io/api/node/v1beta1/types_swagger_doc_generated.go b/staging/src/k8s.io/api/node/v1beta1/types_swagger_doc_generated.go index 6d88710340bd..fec4398b2e71 100644 --- a/staging/src/k8s.io/api/node/v1beta1/types_swagger_doc_generated.go +++ b/staging/src/k8s.io/api/node/v1beta1/types_swagger_doc_generated.go @@ -40,7 +40,7 @@ var map_RuntimeClass = map[string]string{ "": "RuntimeClass defines a class of container runtime supported in the cluster. The RuntimeClass is used to determine which container runtime is used to run all containers in a pod. RuntimeClasses are (currently) manually defined by a user or cluster provisioner, and referenced in the PodSpec. The Kubelet is responsible for resolving the RuntimeClassName reference before running the pod. For more details, see https://git.k8s.io/enhancements/keps/sig-node/585-runtime-class", "metadata": "More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata", "handler": "Handler specifies the underlying runtime and configuration that the CRI implementation will use to handle pods of this class. The possible values are specific to the node & CRI configuration. It is assumed that all handlers are available on every node, and handlers of the same name are equivalent on every node. For example, a handler called \"runc\" might specify that the runc OCI runtime (using native Linux containers) will be used to run the containers in a pod. The Handler must be lowercase, conform to the DNS Label (RFC 1123) requirements, and is immutable.", - "overhead": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md This field is beta-level as of Kubernetes v1.18, and is only honored by servers that enable the PodOverhead feature.", + "overhead": "Overhead represents the resource overhead associated with running a pod for a given RuntimeClass. For more details, see https://git.k8s.io/enhancements/keps/sig-node/688-pod-overhead/README.md", "scheduling": "Scheduling holds the scheduling constraints to ensure that pods running with this RuntimeClass are scheduled to nodes that support it. If scheduling is nil, this RuntimeClass is assumed to be supported by all nodes.", }