diff --git a/pkg/api/pod/util.go b/pkg/api/pod/util.go index a1d536a28b..cb300db782 100644 --- a/pkg/api/pod/util.go +++ b/pkg/api/pod/util.go @@ -318,10 +318,6 @@ func dropDisabledFields( podSpec.PriorityClassName = "" } - if !utilfeature.DefaultFeatureGate.Enabled(features.PodReadinessGates) && !podReadinessGatesInUse(oldPodSpec) { - podSpec.ReadinessGates = nil - } - if !utilfeature.DefaultFeatureGate.Enabled(features.Sysctls) && !sysctlsInUse(oldPodSpec) { if podSpec.SecurityContext != nil { podSpec.SecurityContext.Sysctls = nil @@ -534,17 +530,6 @@ func podPriorityInUse(podSpec *api.PodSpec) bool { return false } -// podReadinessGatesInUse returns true if the pod spec is non-nil and has ReadinessGates -func podReadinessGatesInUse(podSpec *api.PodSpec) bool { - if podSpec == nil { - return false - } - if podSpec.ReadinessGates != nil { - return true - } - return false -} - func sysctlsInUse(podSpec *api.PodSpec) bool { if podSpec == nil { return false diff --git a/pkg/api/pod/util_test.go b/pkg/api/pod/util_test.go index 81402b6bf4..212d77482e 100644 --- a/pkg/api/pod/util_test.go +++ b/pkg/api/pod/util_test.go @@ -1101,102 +1101,6 @@ func TestDropAppArmor(t *testing.T) { } } -func TestDropReadinessGates(t *testing.T) { - podWithoutReadinessGates := func() *api.Pod { - return &api.Pod{ - Spec: api.PodSpec{ - ReadinessGates: nil, - }, - } - } - podWithReadinessGates := func() *api.Pod { - return &api.Pod{ - Spec: api.PodSpec{ - ReadinessGates: []api.PodReadinessGate{ - { - ConditionType: api.PodConditionType("example.com/condition1"), - }, - { - ConditionType: api.PodConditionType("example.com/condition2"), - }, - }, - }, - } - } - - podInfo := []struct { - description string - hasPodReadinessGates bool - pod func() *api.Pod - }{ - { - description: "has ReadinessGates", - hasPodReadinessGates: true, - pod: podWithReadinessGates, - }, - { - description: "does not have ReadinessGates", - hasPodReadinessGates: false, - pod: podWithoutReadinessGates, - }, - { - description: "is nil", - hasPodReadinessGates: false, - pod: func() *api.Pod { return nil }, - }, - } - - for _, enabled := range []bool{true, false} { - for _, oldPodInfo := range podInfo { - for _, newPodInfo := range podInfo { - oldPodHasReadinessGates, oldPod := oldPodInfo.hasPodReadinessGates, oldPodInfo.pod() - newPodHasReadinessGates, newPod := newPodInfo.hasPodReadinessGates, newPodInfo.pod() - if newPod == nil { - continue - } - - t.Run(fmt.Sprintf("featue enabled=%v, old pod %v, new pod %v", enabled, oldPodInfo.description, newPodInfo.description), func(t *testing.T) { - defer utilfeaturetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PodReadinessGates, enabled)() - - var oldPodSpec *api.PodSpec - if oldPod != nil { - oldPodSpec = &oldPod.Spec - } - dropDisabledFields(&newPod.Spec, nil, oldPodSpec, nil) - - // old pod should never be changed - if !reflect.DeepEqual(oldPod, oldPodInfo.pod()) { - t.Errorf("old pod changed: %v", diff.ObjectReflectDiff(oldPod, oldPodInfo.pod())) - } - - switch { - case enabled || oldPodHasReadinessGates: - // new pod should not be changed if the feature is enabled, or if the old pod had ReadinessGates - if !reflect.DeepEqual(newPod, newPodInfo.pod()) { - t.Errorf("new pod changed: %v", diff.ObjectReflectDiff(newPod, newPodInfo.pod())) - } - case newPodHasReadinessGates: - // new pod should be changed - if reflect.DeepEqual(newPod, newPodInfo.pod()) { - t.Errorf("new pod was not changed") - } - // new pod should not have ReadinessGates - if !reflect.DeepEqual(newPod, podWithoutReadinessGates()) { - t.Errorf("new pod had ReadinessGates: %v", - diff.ObjectReflectDiff(newPod, podWithoutReadinessGates())) - } - default: - // new pod should not need to be changed - if !reflect.DeepEqual(newPod, newPodInfo.pod()) { - t.Errorf("new pod changed: %v", diff.ObjectReflectDiff(newPod, newPodInfo.pod())) - } - } - }) - } - } - } -} - func TestDropTokenRequestProjection(t *testing.T) { podWithoutTRProjection := func() *api.Pod { return &api.Pod{ diff --git a/pkg/features/kube_features.go b/pkg/features/kube_features.go index c70a83a37a..e2bed5b725 100644 --- a/pkg/features/kube_features.go +++ b/pkg/features/kube_features.go @@ -310,9 +310,9 @@ const ( BalanceAttachedNodeVolumes utilfeature.Feature = "BalanceAttachedNodeVolumes" // owner @freehan - // beta: v1.11 + // GA: v1.14 // - // Support Pod Ready++ + // Allow user to specify additional conditions to be evaluated for Pod readiness. PodReadinessGates utilfeature.Feature = "PodReadinessGates" // owner: @kevtaylor @@ -480,7 +480,7 @@ var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureS CSIMigrationOpenStack: {Default: false, PreRelease: utilfeature.Alpha}, VolumeSubpath: {Default: true, PreRelease: utilfeature.GA}, BalanceAttachedNodeVolumes: {Default: false, PreRelease: utilfeature.Alpha}, - PodReadinessGates: {Default: true, PreRelease: utilfeature.Beta}, + PodReadinessGates: {Default: true, PreRelease: utilfeature.GA, LockToDefault: true}, // remove in 1.16 VolumeSubpathEnvExpansion: {Default: false, PreRelease: utilfeature.Alpha}, KubeletPluginsWatcher: {Default: true, PreRelease: utilfeature.GA, LockToDefault: true}, // remove in 1.16 ResourceQuotaScopeSelectors: {Default: true, PreRelease: utilfeature.Beta},