From 33713087f43e4fd25fc314dbf5e91afc98a09724 Mon Sep 17 00:00:00 2001 From: Eric Ernst Date: Fri, 26 Apr 2019 12:24:11 -0700 Subject: [PATCH] pod-overhead: drop from PodSpec based on feature-gate Signed-off-by: Eric Ernst --- pkg/api/pod/util.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 {