mirror of https://github.com/k3s-io/k3s
Merge pull request #74434 from freehan/pod-ready-ga
promote PodReadinessGate feature to GApull/564/head
commit
1fc2396e2e
|
@ -318,10 +318,6 @@ func dropDisabledFields(
|
||||||
podSpec.PriorityClassName = ""
|
podSpec.PriorityClassName = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
if !utilfeature.DefaultFeatureGate.Enabled(features.PodReadinessGates) && !podReadinessGatesInUse(oldPodSpec) {
|
|
||||||
podSpec.ReadinessGates = nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if !utilfeature.DefaultFeatureGate.Enabled(features.Sysctls) && !sysctlsInUse(oldPodSpec) {
|
if !utilfeature.DefaultFeatureGate.Enabled(features.Sysctls) && !sysctlsInUse(oldPodSpec) {
|
||||||
if podSpec.SecurityContext != nil {
|
if podSpec.SecurityContext != nil {
|
||||||
podSpec.SecurityContext.Sysctls = nil
|
podSpec.SecurityContext.Sysctls = nil
|
||||||
|
@ -534,17 +530,6 @@ func podPriorityInUse(podSpec *api.PodSpec) bool {
|
||||||
return false
|
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 {
|
func sysctlsInUse(podSpec *api.PodSpec) bool {
|
||||||
if podSpec == nil {
|
if podSpec == nil {
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -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) {
|
func TestDropTokenRequestProjection(t *testing.T) {
|
||||||
podWithoutTRProjection := func() *api.Pod {
|
podWithoutTRProjection := func() *api.Pod {
|
||||||
return &api.Pod{
|
return &api.Pod{
|
||||||
|
|
|
@ -310,9 +310,9 @@ const (
|
||||||
BalanceAttachedNodeVolumes utilfeature.Feature = "BalanceAttachedNodeVolumes"
|
BalanceAttachedNodeVolumes utilfeature.Feature = "BalanceAttachedNodeVolumes"
|
||||||
|
|
||||||
// owner @freehan
|
// 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"
|
PodReadinessGates utilfeature.Feature = "PodReadinessGates"
|
||||||
|
|
||||||
// owner: @kevtaylor
|
// owner: @kevtaylor
|
||||||
|
@ -480,7 +480,7 @@ var defaultKubernetesFeatureGates = map[utilfeature.Feature]utilfeature.FeatureS
|
||||||
CSIMigrationOpenStack: {Default: false, PreRelease: utilfeature.Alpha},
|
CSIMigrationOpenStack: {Default: false, PreRelease: utilfeature.Alpha},
|
||||||
VolumeSubpath: {Default: true, PreRelease: utilfeature.GA},
|
VolumeSubpath: {Default: true, PreRelease: utilfeature.GA},
|
||||||
BalanceAttachedNodeVolumes: {Default: false, PreRelease: utilfeature.Alpha},
|
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},
|
VolumeSubpathEnvExpansion: {Default: false, PreRelease: utilfeature.Alpha},
|
||||||
KubeletPluginsWatcher: {Default: true, PreRelease: utilfeature.GA, LockToDefault: true}, // remove in 1.16
|
KubeletPluginsWatcher: {Default: true, PreRelease: utilfeature.GA, LockToDefault: true}, // remove in 1.16
|
||||||
ResourceQuotaScopeSelectors: {Default: true, PreRelease: utilfeature.Beta},
|
ResourceQuotaScopeSelectors: {Default: true, PreRelease: utilfeature.Beta},
|
||||||
|
|
Loading…
Reference in New Issue