Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graduate NonPreemptingPriority to GA #107432

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/openapi-spec/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/openapi-spec/v3/api__v1_openapi.json
Expand Up @@ -4309,7 +4309,7 @@
"type": "object"
},
"preemptionPolicy": {
"description": "PreemptionPolicy is the Policy for preempting pods with lower priority. One of Never, PreemptLowerPriority. Defaults to PreemptLowerPriority if unset. This field is beta-level, gated by the NonPreemptingPriority feature-gate.",
"description": "PreemptionPolicy is the Policy for preempting pods with lower priority. One of Never, PreemptLowerPriority. Defaults to PreemptLowerPriority if unset.",
"type": "string"
},
"priority": {
Expand Down
2 changes: 1 addition & 1 deletion api/openapi-spec/v3/apis__apps__v1_openapi.json
Expand Up @@ -2999,7 +2999,7 @@
"type": "object"
},
"preemptionPolicy": {
"description": "PreemptionPolicy is the Policy for preempting pods with lower priority. One of Never, PreemptLowerPriority. Defaults to PreemptLowerPriority if unset. This field is beta-level, gated by the NonPreemptingPriority feature-gate.",
"description": "PreemptionPolicy is the Policy for preempting pods with lower priority. One of Never, PreemptLowerPriority. Defaults to PreemptLowerPriority if unset.",
"type": "string"
},
"priority": {
Expand Down
2 changes: 1 addition & 1 deletion api/openapi-spec/v3/apis__batch__v1_openapi.json
Expand Up @@ -2225,7 +2225,7 @@
"type": "object"
},
"preemptionPolicy": {
"description": "PreemptionPolicy is the Policy for preempting pods with lower priority. One of Never, PreemptLowerPriority. Defaults to PreemptLowerPriority if unset. This field is beta-level, gated by the NonPreemptingPriority feature-gate.",
"description": "PreemptionPolicy is the Policy for preempting pods with lower priority. One of Never, PreemptLowerPriority. Defaults to PreemptLowerPriority if unset.",
"type": "string"
},
"priority": {
Expand Down
2 changes: 1 addition & 1 deletion api/openapi-spec/v3/apis__batch__v1beta1_openapi.json
Expand Up @@ -2027,7 +2027,7 @@
"type": "object"
},
"preemptionPolicy": {
"description": "PreemptionPolicy is the Policy for preempting pods with lower priority. One of Never, PreemptLowerPriority. Defaults to PreemptLowerPriority if unset. This field is beta-level, gated by the NonPreemptingPriority feature-gate.",
"description": "PreemptionPolicy is the Policy for preempting pods with lower priority. One of Never, PreemptLowerPriority. Defaults to PreemptLowerPriority if unset.",
"type": "string"
},
"priority": {
Expand Down
Expand Up @@ -26,7 +26,7 @@
"description": "Standard object's metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata"
},
"preemptionPolicy": {
"description": "PreemptionPolicy is the Policy for preempting pods with lower priority. One of Never, PreemptLowerPriority. Defaults to PreemptLowerPriority if unset. This field is beta-level, gated by the NonPreemptingPriority feature-gate.",
"description": "PreemptionPolicy is the Policy for preempting pods with lower priority. One of Never, PreemptLowerPriority. Defaults to PreemptLowerPriority if unset.",
"type": "string"
},
"value": {
Expand Down
17 changes: 0 additions & 17 deletions pkg/api/pod/util.go
Expand Up @@ -580,12 +580,6 @@ func dropDisabledFields(

dropDisabledCSIVolumeSourceAlphaFields(podSpec, oldPodSpec)

if !utilfeature.DefaultFeatureGate.Enabled(features.NonPreemptingPriority) &&
!podPriorityInUse(oldPodSpec) {
// Set to nil pod's PreemptionPolicy fields if the feature is disabled and the old pod
// does not specify any values for these fields.
podSpec.PreemptionPolicy = nil
}
if !utilfeature.DefaultFeatureGate.Enabled(features.IdentifyPodOS) && !podOSInUse(oldPodSpec) {
podSpec.OS = nil
}
Expand Down Expand Up @@ -740,17 +734,6 @@ func appArmorInUse(podAnnotations map[string]string) bool {
return false
}

// podPriorityInUse returns true if the pod spec is non-nil and has Priority or PriorityClassName set.
func podPriorityInUse(podSpec *api.PodSpec) bool {
if podSpec == nil {
return false
}
if podSpec.Priority != nil || podSpec.PriorityClassName != "" {
return true
}
return false
}

// emptyDirSizeLimitInUse returns true if any pod's EmptyDir volumes use SizeLimit.
func emptyDirSizeLimitInUse(podSpec *api.PodSpec) bool {
if podSpec == nil {
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/core/types.go
Expand Up @@ -2918,7 +2918,6 @@ type PodSpec struct {
// PreemptionPolicy is the Policy for preempting pods with lower priority.
// One of Never, PreemptLowerPriority.
// Defaults to PreemptLowerPriority if unset.
// This field is beta-level, gated by the NonPreemptingPriority feature-gate.
// +optional
PreemptionPolicy *PreemptionPolicy
// Specifies the DNS parameters of a pod.
Expand Down
4 changes: 1 addition & 3 deletions pkg/apis/scheduling/fuzzer/fuzzer.go
Expand Up @@ -19,18 +19,16 @@ package fuzzer
import (
"github.com/google/gofuzz"
runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/kubernetes/pkg/apis/core"
"k8s.io/kubernetes/pkg/apis/scheduling"
"k8s.io/kubernetes/pkg/features"
)

// Funcs returns the fuzzer functions for the scheduling api group.
var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} {
return []interface{}{
func(s *scheduling.PriorityClass, c fuzz.Continue) {
c.FuzzNoCustom(s)
if utilfeature.DefaultFeatureGate.Enabled(features.NonPreemptingPriority) && s.PreemptionPolicy == nil {
if s.PreemptionPolicy == nil {
preemptLowerPriority := core.PreemptLowerPriority
s.PreemptionPolicy = &preemptLowerPriority
}
Expand Down
40 changes: 0 additions & 40 deletions pkg/apis/scheduling/util/util.go

This file was deleted.

109 changes: 0 additions & 109 deletions pkg/apis/scheduling/util/util_test.go

This file was deleted.

6 changes: 2 additions & 4 deletions pkg/apis/scheduling/v1/defaults.go
Expand Up @@ -18,10 +18,8 @@ package v1

import (
apiv1 "k8s.io/api/core/v1"
"k8s.io/api/scheduling/v1"
v1 "k8s.io/api/scheduling/v1"
"k8s.io/apimachinery/pkg/runtime"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/kubernetes/pkg/features"
)

func addDefaultingFuncs(scheme *runtime.Scheme) error {
Expand All @@ -31,7 +29,7 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error {
// SetDefaults_PriorityClass sets additional defaults compared to its counterpart
// in extensions.
func SetDefaults_PriorityClass(obj *v1.PriorityClass) {
if utilfeature.DefaultFeatureGate.Enabled(features.NonPreemptingPriority) && obj.PreemptionPolicy == nil {
if obj.PreemptionPolicy == nil {
preemptLowerPriority := apiv1.PreemptLowerPriority
obj.PreemptionPolicy = &preemptLowerPriority
}
Expand Down
6 changes: 0 additions & 6 deletions pkg/apis/scheduling/v1/defaults_test.go
Expand Up @@ -23,10 +23,7 @@ import (
apiv1 "k8s.io/api/core/v1"
v1 "k8s.io/api/scheduling/v1"
"k8s.io/apimachinery/pkg/runtime"
utilfeature "k8s.io/apiserver/pkg/util/feature"
featuregatetesting "k8s.io/component-base/featuregate/testing"
"k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/features"

// ensure types are installed
_ "k8s.io/kubernetes/pkg/apis/scheduling/install"
Expand Down Expand Up @@ -56,9 +53,6 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
func TestSetDefaultPreemptionPolicy(t *testing.T) {
priorityClass := &v1.PriorityClass{}

// set NonPreemptingPriority true
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.NonPreemptingPriority, true)()

output := roundTrip(t, runtime.Object(priorityClass)).(*v1.PriorityClass)
if output.PreemptionPolicy == nil || *output.PreemptionPolicy != apiv1.PreemptLowerPriority {
t.Errorf("Expected PriorityClass.PreemptionPolicy value: %+v\ngot: %+v\n", apiv1.PreemptLowerPriority, output.PreemptionPolicy)
Expand Down
4 changes: 1 addition & 3 deletions pkg/apis/scheduling/v1alpha1/defaults.go
Expand Up @@ -20,8 +20,6 @@ import (
apiv1 "k8s.io/api/core/v1"
"k8s.io/api/scheduling/v1alpha1"
runtime "k8s.io/apimachinery/pkg/runtime"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/kubernetes/pkg/features"
)

func addDefaultingFuncs(scheme *runtime.Scheme) error {
Expand All @@ -31,7 +29,7 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error {
// SetDefaults_PriorityClass sets additional defaults compared to its counterpart
// in extensions.
func SetDefaults_PriorityClass(obj *v1alpha1.PriorityClass) {
if utilfeature.DefaultFeatureGate.Enabled(features.NonPreemptingPriority) && obj.PreemptionPolicy == nil {
if obj.PreemptionPolicy == nil {
preemptLowerPriority := apiv1.PreemptLowerPriority
obj.PreemptionPolicy = &preemptLowerPriority
}
Expand Down
6 changes: 0 additions & 6 deletions pkg/apis/scheduling/v1alpha1/defaults_test.go
Expand Up @@ -23,10 +23,7 @@ import (
apiv1 "k8s.io/api/core/v1"
"k8s.io/api/scheduling/v1alpha1"
"k8s.io/apimachinery/pkg/runtime"
utilfeature "k8s.io/apiserver/pkg/util/feature"
featuregatetesting "k8s.io/component-base/featuregate/testing"
"k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/features"

// ensure types are installed
_ "k8s.io/kubernetes/pkg/apis/scheduling/install"
Expand Down Expand Up @@ -56,9 +53,6 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
func TestSetDefaultPreempting(t *testing.T) {
priorityClass := &v1alpha1.PriorityClass{}

// set NonPreemptingPriority true
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.NonPreemptingPriority, true)()

output := roundTrip(t, runtime.Object(priorityClass)).(*v1alpha1.PriorityClass)
if output.PreemptionPolicy == nil || *output.PreemptionPolicy != apiv1.PreemptLowerPriority {
t.Errorf("Expected PriorityClass.Preempting value: %+v\ngot: %+v\n", apiv1.PreemptLowerPriority, output.PreemptionPolicy)
Expand Down
4 changes: 1 addition & 3 deletions pkg/apis/scheduling/v1beta1/defaults.go
Expand Up @@ -20,8 +20,6 @@ import (
apiv1 "k8s.io/api/core/v1"
"k8s.io/api/scheduling/v1beta1"
runtime "k8s.io/apimachinery/pkg/runtime"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/kubernetes/pkg/features"
)

func addDefaultingFuncs(scheme *runtime.Scheme) error {
Expand All @@ -31,7 +29,7 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error {
// SetDefaults_PriorityClass sets additional defaults compared to its counterpart
// in extensions.
func SetDefaults_PriorityClass(obj *v1beta1.PriorityClass) {
if utilfeature.DefaultFeatureGate.Enabled(features.NonPreemptingPriority) && obj.PreemptionPolicy == nil {
if obj.PreemptionPolicy == nil {
preemptLowerPriority := apiv1.PreemptLowerPriority
obj.PreemptionPolicy = &preemptLowerPriority
}
Expand Down
6 changes: 0 additions & 6 deletions pkg/apis/scheduling/v1beta1/defaults_test.go
Expand Up @@ -23,10 +23,7 @@ import (
apiv1 "k8s.io/api/core/v1"
"k8s.io/api/scheduling/v1beta1"
"k8s.io/apimachinery/pkg/runtime"
utilfeature "k8s.io/apiserver/pkg/util/feature"
featuregatetesting "k8s.io/component-base/featuregate/testing"
"k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/features"

// ensure types are installed
_ "k8s.io/kubernetes/pkg/apis/scheduling/install"
Expand Down Expand Up @@ -56,9 +53,6 @@ func roundTrip(t *testing.T, obj runtime.Object) runtime.Object {
func TestSetDefaultPreempting(t *testing.T) {
priorityClass := &v1beta1.PriorityClass{}

// set NonPreemptingPriority true
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.NonPreemptingPriority, true)()

output := roundTrip(t, runtime.Object(priorityClass)).(*v1beta1.PriorityClass)
if output.PreemptionPolicy == nil || *output.PreemptionPolicy != apiv1.PreemptLowerPriority {
t.Errorf("Expected PriorityClass.Preempting value: %+v\ngot: %+v\n", apiv1.PreemptLowerPriority, output.PreemptionPolicy)
Expand Down