pod overhead: drop from RuntimeClass base on feature-gate

Signed-off-by: Eric Ernst <eric.ernst@intel.com>
This commit is contained in:
Eric Ernst 2019-06-17 12:42:05 -07:00
parent 2c52cc3412
commit ec8ef0df20

View File

@ -23,9 +23,11 @@ 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.
@ -56,7 +58,12 @@ 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) {
_ = obj.(*node.RuntimeClass)
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.