diff --git a/pkg/api/pod/util.go b/pkg/api/pod/util.go index 6c80edcc994..7b7dbafda84 100644 --- a/pkg/api/pod/util.go +++ b/pkg/api/pod/util.go @@ -375,6 +375,11 @@ func dropDisabledFields( podSpec.RuntimeClassName = nil } + 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) @@ -524,6 +529,18 @@ func runtimeClassInUse(podSpec *api.PodSpec) bool { return false } +// 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 {