Skip to content

Commit 68d3458

Browse files
committed
promote PDBUnhealthyPodEvictionPolicy to GA
1 parent 9de747c commit 68d3458

File tree

6 files changed

+37
-302
lines changed

6 files changed

+37
-302
lines changed

pkg/features/kube_features.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ const (
520520
// kep: http://kep.k8s.io/3018
521521
// alpha: v1.26
522522
// beta: v1.27
523+
// GA: v1.31
523524
//
524525
// Enables PDBUnhealthyPodEvictionPolicy for PodDisruptionBudgets
525526
PDBUnhealthyPodEvictionPolicy featuregate.Feature = "PDBUnhealthyPodEvictionPolicy"
@@ -1086,7 +1087,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
10861087

10871088
NodeSwap: {Default: true, PreRelease: featuregate.Beta},
10881089

1089-
PDBUnhealthyPodEvictionPolicy: {Default: true, PreRelease: featuregate.Beta},
1090+
PDBUnhealthyPodEvictionPolicy: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.33
10901091

10911092
PersistentVolumeLastPhaseTransitionTime: {Default: true, PreRelease: featuregate.Beta},
10921093

pkg/registry/core/pod/storage/eviction.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,10 @@ func (r *EvictionREST) Create(ctx context.Context, name string, obj runtime.Obje
230230
// IsPodReady is the current implementation of IsHealthy
231231
// If the pod is healthy, it should be guarded by the PDB.
232232
if !podutil.IsPodReady(pod) {
233-
if feature.DefaultFeatureGate.Enabled(features.PDBUnhealthyPodEvictionPolicy) {
234-
if pdb.Spec.UnhealthyPodEvictionPolicy != nil && *pdb.Spec.UnhealthyPodEvictionPolicy == policyv1.AlwaysAllow {
235-
// Delete the unhealthy pod, it doesn't count towards currentHealthy and desiredHealthy and we should not decrement disruptionsAllowed.
236-
updateDeletionOptions = true
237-
return nil
238-
}
233+
if pdb.Spec.UnhealthyPodEvictionPolicy != nil && *pdb.Spec.UnhealthyPodEvictionPolicy == policyv1.AlwaysAllow {
234+
// Delete the unhealthy pod, it doesn't count towards currentHealthy and desiredHealthy and we should not decrement disruptionsAllowed.
235+
updateDeletionOptions = true
236+
return nil
239237
}
240238
// default nil and IfHealthyBudget policy
241239
if pdb.Status.CurrentHealthy >= pdb.Status.DesiredHealthy && pdb.Status.DesiredHealthy > 0 {

pkg/registry/core/pod/storage/eviction_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,6 @@ func TestEviction(t *testing.T) {
165165
continue
166166
}
167167
t.Run(fmt.Sprintf("%v with %v policy", tc.name, unhealthyPolicyStr(unhealthyPodEvictionPolicy)), func(t *testing.T) {
168-
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PDBUnhealthyPodEvictionPolicy, true)
169-
170168
// same test runs multiple times, make copy of objects to have unique ones
171169
evictionCopy := tc.eviction.DeepCopy()
172170
var pdbsCopy []runtime.Object
@@ -530,8 +528,6 @@ func TestEvictionIgnorePDB(t *testing.T) {
530528
continue
531529
}
532530
t.Run(fmt.Sprintf("%v with %v policy", tc.name, unhealthyPolicyStr(unhealthyPodEvictionPolicy)), func(t *testing.T) {
533-
featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.PDBUnhealthyPodEvictionPolicy, true)
534-
535531
// same test runs 3 times, make copy of objects to have unique ones
536532
evictionCopy := tc.eviction.DeepCopy()
537533
prcCopy := tc.prc.DeepCopy()

pkg/registry/policy/poddisruptionbudget/strategy.go

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@ import (
2626
"k8s.io/apimachinery/pkg/util/validation/field"
2727
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
2828
"k8s.io/apiserver/pkg/storage/names"
29-
utilfeature "k8s.io/apiserver/pkg/util/feature"
3029
"k8s.io/kubernetes/pkg/api/legacyscheme"
3130
"k8s.io/kubernetes/pkg/apis/policy"
3231
"k8s.io/kubernetes/pkg/apis/policy/validation"
33-
"k8s.io/kubernetes/pkg/features"
3432
"sigs.k8s.io/structured-merge-diff/v4/fieldpath"
3533
)
3634

@@ -70,8 +68,6 @@ func (podDisruptionBudgetStrategy) PrepareForCreate(ctx context.Context, obj run
7068
podDisruptionBudget.Status = policy.PodDisruptionBudgetStatus{}
7169

7270
podDisruptionBudget.Generation = 1
73-
74-
dropDisabledFields(&podDisruptionBudget.Spec, nil)
7571
}
7672

7773
// PrepareForUpdate clears fields that are not allowed to be set by end users on update.
@@ -87,8 +83,6 @@ func (podDisruptionBudgetStrategy) PrepareForUpdate(ctx context.Context, obj, ol
8783
if !apiequality.Semantic.DeepEqual(oldPodDisruptionBudget.Spec, newPodDisruptionBudget.Spec) {
8884
newPodDisruptionBudget.Generation = oldPodDisruptionBudget.Generation + 1
8985
}
90-
91-
dropDisabledFields(&newPodDisruptionBudget.Spec, &oldPodDisruptionBudget.Spec)
9286
}
9387

9488
// Validate validates a new PodDisruptionBudget.
@@ -188,23 +182,3 @@ func hasInvalidLabelValueInLabelSelector(pdb *policy.PodDisruptionBudget) bool {
188182
}
189183
return false
190184
}
191-
192-
// dropDisabledFields removes disabled fields from the pod disruption budget spec.
193-
// This should be called from PrepareForCreate/PrepareForUpdate for all resources containing a pod disruption budget spec.
194-
func dropDisabledFields(pdbSpec, oldPDBSpec *policy.PodDisruptionBudgetSpec) {
195-
if !utilfeature.DefaultFeatureGate.Enabled(features.PDBUnhealthyPodEvictionPolicy) {
196-
if !unhealthyPodEvictionPolicyInUse(oldPDBSpec) {
197-
pdbSpec.UnhealthyPodEvictionPolicy = nil
198-
}
199-
}
200-
}
201-
202-
func unhealthyPodEvictionPolicyInUse(oldPDBSpec *policy.PodDisruptionBudgetSpec) bool {
203-
if oldPDBSpec == nil {
204-
return false
205-
}
206-
if oldPDBSpec.UnhealthyPodEvictionPolicy != nil {
207-
return true
208-
}
209-
return false
210-
}

0 commit comments

Comments
 (0)