From f4e238fd8d45ff81b0c102cf58228daa66c0d5bc Mon Sep 17 00:00:00 2001 From: berg Date: Wed, 3 Jan 2024 19:18:18 +0800 Subject: [PATCH] fix deleteAvailableLimit bug (#1481) * fix deleteAvailableLimit bug Signed-off-by: liheng.zms * add clonesets scale ut Signed-off-by: liheng.zms --------- Signed-off-by: liheng.zms --- .../cloneset/sync/cloneset_scale.go | 18 +- .../cloneset/sync/cloneset_scale_test.go | 247 ++++++++++++++++++ .../cloneset/sync/cloneset_sync_utils.go | 10 +- .../cloneset/sync/cloneset_sync_utils_test.go | 40 +-- 4 files changed, 280 insertions(+), 35 deletions(-) diff --git a/pkg/controller/cloneset/sync/cloneset_scale.go b/pkg/controller/cloneset/sync/cloneset_scale.go index c78399e38c..acd06bbe66 100644 --- a/pkg/controller/cloneset/sync/cloneset_scale.go +++ b/pkg/controller/cloneset/sync/cloneset_scale.go @@ -110,15 +110,16 @@ func (r *realControl) Scale( if podsToDelete := util.DiffPods(podsSpecifiedToDelete, podsInPreDelete); len(podsToDelete) > 0 { newPodsToDelete, oldPodsToDelete := clonesetutils.GroupUpdateAndNotUpdatePods(podsToDelete, updateRevision) klog.V(3).Infof("CloneSet %s try to delete pods specified. Delete ready limit: %d. New Pods: %v, old Pods: %v.", - controllerKey, diffRes.deleteReadyLimit, util.GetPodNames(newPodsToDelete).List(), util.GetPodNames(oldPodsToDelete).List()) + controllerKey, diffRes.deleteAvailableLimit, util.GetPodNames(newPodsToDelete).List(), util.GetPodNames(oldPodsToDelete).List()) podsCanDelete := make([]*v1.Pod, 0, len(podsToDelete)) for _, pod := range podsToDelete { - if !isPodReady(coreControl, pod) { + // Determine pod available, since deleteAvailableLimit is also based on the pod available calculation + if !IsPodAvailable(coreControl, pod, updateCS.Spec.MinReadySeconds) { podsCanDelete = append(podsCanDelete, pod) - } else if diffRes.deleteReadyLimit > 0 { + } else if diffRes.deleteAvailableLimit > 0 { podsCanDelete = append(podsCanDelete, pod) - diffRes.deleteReadyLimit-- + diffRes.deleteAvailableLimit-- } } @@ -136,16 +137,17 @@ func (r *realControl) Scale( } klog.V(3).Infof("CloneSet %s begin to scale in %d pods including %d (current rev), delete ready limit: %d", - controllerKey, diffRes.scaleDownNum, diffRes.scaleDownNumOldRevision, diffRes.deleteReadyLimit) + controllerKey, diffRes.scaleDownNum, diffRes.scaleDownNumOldRevision, diffRes.deleteAvailableLimit) podsPreparingToDelete := r.choosePodsToDelete(updateCS, diffRes.scaleDownNum, diffRes.scaleDownNumOldRevision, notUpdatedPods, updatedPods) podsToDelete := make([]*v1.Pod, 0, len(podsPreparingToDelete)) for _, pod := range podsPreparingToDelete { - if !isPodReady(coreControl, pod) { + // Determine pod available, since deleteAvailableLimit is also based on the pod available calculation + if !IsPodAvailable(coreControl, pod, updateCS.Spec.MinReadySeconds) { podsToDelete = append(podsToDelete, pod) - } else if diffRes.deleteReadyLimit > 0 { + } else if diffRes.deleteAvailableLimit > 0 { podsToDelete = append(podsToDelete, pod) - diffRes.deleteReadyLimit-- + diffRes.deleteAvailableLimit-- } } diff --git a/pkg/controller/cloneset/sync/cloneset_scale_test.go b/pkg/controller/cloneset/sync/cloneset_scale_test.go index 4221145f6f..4f01e3447f 100644 --- a/pkg/controller/cloneset/sync/cloneset_scale_test.go +++ b/pkg/controller/cloneset/sync/cloneset_scale_test.go @@ -18,9 +18,11 @@ package sync import ( "context" + "fmt" "reflect" "sort" "testing" + "time" appspub "github.com/openkruise/kruise/apis/apps/pub" appsv1alpha1 "github.com/openkruise/kruise/apis/apps/v1alpha1" @@ -32,12 +34,29 @@ import ( v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/util/intstr" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" "k8s.io/apimachinery/pkg/util/sets" + "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/tools/record" + corev1 "k8s.io/kubernetes/pkg/apis/core/v1" + kubecontroller "k8s.io/kubernetes/pkg/controller" + utilpointer "k8s.io/utils/pointer" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/client/fake" ) +var ( + kscheme *runtime.Scheme +) + +func init() { + kscheme = runtime.NewScheme() + utilruntime.Must(appsv1alpha1.AddToScheme(scheme.Scheme)) + utilruntime.Must(corev1.AddToScheme(kscheme)) +} + func newFakeControl() *realControl { return &realControl{ Client: fake.NewClientBuilder().Build(), @@ -527,3 +546,231 @@ func TestGetOrGenAvailableIDs(t *testing.T) { t.Fatalf("expected got random id, but actually %v", id) } } + +func TestScale(t *testing.T) { + cases := []struct { + name string + getCloneSets func() [2]*appsv1alpha1.CloneSet + getRevisions func() [2]string + getPods func() []*v1.Pod + expectedPodsLen int + expectedModified bool + }{ + { + name: "cloneSet(replicas=3,maxUnavailable=20%,partition=nil,maxSurge=nil,minReadySeconds=9999), pods=5, and scale replicas 5 -> 3", + getCloneSets: func() [2]*appsv1alpha1.CloneSet { + obj := &appsv1alpha1.CloneSet{ + ObjectMeta: metav1.ObjectMeta{ + Name: "sample", + }, + Spec: appsv1alpha1.CloneSetSpec{ + Replicas: utilpointer.Int32(3), + MinReadySeconds: 9999, + UpdateStrategy: appsv1alpha1.CloneSetUpdateStrategy{ + MaxUnavailable: &intstr.IntOrString{ + Type: intstr.String, + StrVal: "20%", + }, + }, + }, + } + return [2]*appsv1alpha1.CloneSet{obj.DeepCopy(), obj.DeepCopy()} + }, + getRevisions: func() [2]string { + return [2]string{"sample-b976d4544", "sample-b976d4544"} + }, + getPods: func() []*v1.Pod { + t := time.Now().Add(-time.Second * 10) + obj := &v1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "sample", + Labels: map[string]string{ + apps.ControllerRevisionHashLabelKey: "sample-b976d4544", + }, + }, + Spec: v1.PodSpec{ + Containers: []v1.Container{ + { + Name: "main", + Image: "sample:v1", + }, + }, + }, + Status: v1.PodStatus{ + Phase: v1.PodRunning, + Conditions: []v1.PodCondition{ + { + Type: v1.PodReady, + Status: v1.ConditionTrue, + LastTransitionTime: metav1.Time{Time: t}, + }, + }, + }, + } + return generatePods(obj, 5) + }, + expectedPodsLen: 3, + expectedModified: true, + }, + { + name: "cloneSet(replicas=3,maxUnavailable=20%,partition=nil,maxSurge=nil,minReadySeconds=0), specified delete pod-0, pods=5, and scale replicas 5 -> 3", + getCloneSets: func() [2]*appsv1alpha1.CloneSet { + obj := &appsv1alpha1.CloneSet{ + ObjectMeta: metav1.ObjectMeta{ + Name: "sample", + }, + Spec: appsv1alpha1.CloneSetSpec{ + Replicas: utilpointer.Int32(3), + UpdateStrategy: appsv1alpha1.CloneSetUpdateStrategy{ + MaxUnavailable: &intstr.IntOrString{ + Type: intstr.String, + StrVal: "20%", + }, + }, + }, + } + return [2]*appsv1alpha1.CloneSet{obj.DeepCopy(), obj.DeepCopy()} + }, + getRevisions: func() [2]string { + return [2]string{"sample-b976d4544", "sample-b976d4544"} + }, + getPods: func() []*v1.Pod { + t := time.Now().Add(-time.Second * 10) + obj := &v1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "sample", + Labels: map[string]string{ + apps.ControllerRevisionHashLabelKey: "sample-b976d4544", + }, + }, + Spec: v1.PodSpec{ + Containers: []v1.Container{ + { + Name: "main", + Image: "sample:v1", + }, + }, + }, + Status: v1.PodStatus{ + Phase: v1.PodRunning, + Conditions: []v1.PodCondition{ + { + Type: v1.PodReady, + Status: v1.ConditionTrue, + LastTransitionTime: metav1.Time{Time: t}, + }, + }, + }, + } + pods := generatePods(obj, 5) + pods[0].Labels[appsv1alpha1.SpecifiedDeleteKey] = "true" + return pods + }, + expectedPodsLen: 4, + expectedModified: true, + }, + { + name: "cloneSet(replicas=3,maxUnavailable=20%,partition=nil,maxSurge=nil,minReadySeconds=0), pods=5, and scale replicas 5 -> 3", + getCloneSets: func() [2]*appsv1alpha1.CloneSet { + obj := &appsv1alpha1.CloneSet{ + ObjectMeta: metav1.ObjectMeta{ + Name: "sample", + }, + Spec: appsv1alpha1.CloneSetSpec{ + Replicas: utilpointer.Int32(3), + UpdateStrategy: appsv1alpha1.CloneSetUpdateStrategy{ + MaxUnavailable: &intstr.IntOrString{ + Type: intstr.String, + StrVal: "20%", + }, + }, + }, + } + return [2]*appsv1alpha1.CloneSet{obj.DeepCopy(), obj.DeepCopy()} + }, + getRevisions: func() [2]string { + return [2]string{"sample-b976d4544", "sample-b976d4544"} + }, + getPods: func() []*v1.Pod { + t := time.Now().Add(-time.Second * 10) + obj := &v1.Pod{ + ObjectMeta: metav1.ObjectMeta{ + Name: "sample", + Labels: map[string]string{ + apps.ControllerRevisionHashLabelKey: "sample-b976d4544", + }, + }, + Spec: v1.PodSpec{ + Containers: []v1.Container{ + { + Name: "main", + Image: "sample:v1", + }, + }, + }, + Status: v1.PodStatus{ + Phase: v1.PodRunning, + Conditions: []v1.PodCondition{ + { + Type: v1.PodReady, + Status: v1.ConditionTrue, + LastTransitionTime: metav1.Time{Time: t}, + }, + }, + }, + } + return generatePods(obj, 5) + }, + expectedPodsLen: 3, + expectedModified: true, + }, + } + + for _, cs := range cases { + t.Run(cs.name, func(t *testing.T) { + fClient := fake.NewClientBuilder().WithScheme(kscheme).Build() + pods := cs.getPods() + for _, pod := range pods { + err := fClient.Create(context.TODO(), pod) + if err != nil { + t.Fatalf(err.Error()) + } + } + rControl := &realControl{ + Client: fClient, + recorder: record.NewFakeRecorder(10), + } + modified, err := rControl.Scale(cs.getCloneSets()[0], cs.getCloneSets()[1], cs.getRevisions()[0], cs.getRevisions()[1], pods, nil) + if err != nil { + t.Fatalf(err.Error()) + } + if cs.expectedModified != modified { + t.Fatalf("expect(%v), but get(%v)", cs.expectedModified, modified) + } + podList := &v1.PodList{} + err = fClient.List(context.TODO(), podList, &client.ListOptions{}) + if err != nil { + t.Fatalf(err.Error()) + } + actives := 0 + for _, pod := range podList.Items { + if kubecontroller.IsPodActive(&pod) { + actives++ + } + } + if actives != cs.expectedPodsLen { + t.Fatalf("expect(%v), but get(%v)", cs.expectedPodsLen, actives) + } + }) + } +} + +func generatePods(base *v1.Pod, replicas int) []*v1.Pod { + objs := make([]*v1.Pod, 0, replicas) + for i := 0; i < replicas; i++ { + obj := base.DeepCopy() + obj.Name = fmt.Sprintf("%s-%d", base.Name, i) + objs = append(objs, obj) + } + return objs +} diff --git a/pkg/controller/cloneset/sync/cloneset_sync_utils.go b/pkg/controller/cloneset/sync/cloneset_sync_utils.go index 9a7bd19649..3ba1e95641 100644 --- a/pkg/controller/cloneset/sync/cloneset_sync_utils.go +++ b/pkg/controller/cloneset/sync/cloneset_sync_utils.go @@ -63,9 +63,9 @@ type expectationDiffs struct { // scaleUpLimit is the limit number of creating Pods when scaling up // it is limited by scaleStrategy.maxUnavailable scaleUpLimit int - // deleteReadyLimit is the limit number of ready Pods that can be deleted + // deleteAvailableLimit is the limit number of ready Pods that can be deleted // it is limited by UpdateStrategy.maxUnavailable - deleteReadyLimit int + deleteAvailableLimit int // useSurge is the number that temporarily expect to be above the desired replicas useSurge int @@ -253,7 +253,7 @@ func calculateDiffsWithExpectation(cs *appsv1alpha1.CloneSet, pods []*v1.Pod, cu res.scaleDownNumOldRevision = integer.IntMax(currentTotalOldCount-toDeleteOldRevisionCount-expectedTotalOldCount, 0) } if toDeleteNewRevisionCount > 0 || toDeleteOldRevisionCount > 0 || res.scaleDownNum > 0 { - res.deleteReadyLimit = integer.IntMax(maxUnavailable+(len(pods)-replicas)-totalUnavailable, 0) + res.deleteAvailableLimit = integer.IntMax(maxUnavailable+(len(pods)-replicas)-totalUnavailable, 0) } // The consistency between scale and update will be guaranteed by syncCloneSet and expectations @@ -281,10 +281,6 @@ func isSpecifiedDelete(cs *appsv1alpha1.CloneSet, pod *v1.Pod) bool { return false } -func isPodReady(coreControl clonesetcore.Control, pod *v1.Pod) bool { - return IsPodAvailable(coreControl, pod, 0) -} - func IsPodAvailable(coreControl clonesetcore.Control, pod *v1.Pod, minReadySeconds int32) bool { state := lifecycle.GetPodLifecycleState(pod) if state != "" && state != appspub.LifecycleStateNormal { diff --git a/pkg/controller/cloneset/sync/cloneset_sync_utils_test.go b/pkg/controller/cloneset/sync/cloneset_sync_utils_test.go index 50dd0926b5..18bd5ee1f8 100644 --- a/pkg/controller/cloneset/sync/cloneset_sync_utils_test.go +++ b/pkg/controller/cloneset/sync/cloneset_sync_utils_test.go @@ -80,7 +80,7 @@ func TestCalculateDiffsWithExpectation(t *testing.T) { createTestPod(newRevision, appspub.LifecycleStateNormal, true, false), createTestPod(newRevision, appspub.LifecycleStateNormal, true, false), }, - expectResult: expectationDiffs{deleteReadyLimit: 1}, + expectResult: expectationDiffs{deleteAvailableLimit: 1}, }, { name: "specified delete 1 pod (all ready) (step 2/3)", @@ -115,7 +115,7 @@ func TestCalculateDiffsWithExpectation(t *testing.T) { createTestPod(newRevision, appspub.LifecycleStateNormal, true, false), createTestPod(newRevision, appspub.LifecycleStateNormal, true, false), }, - expectResult: expectationDiffs{deleteReadyLimit: 1}, + expectResult: expectationDiffs{deleteAvailableLimit: 1}, }, { name: "specified delete 2 pod (all ready) (step 2/6)", @@ -150,7 +150,7 @@ func TestCalculateDiffsWithExpectation(t *testing.T) { createTestPod(newRevision, appspub.LifecycleStateNormal, true, false), createTestPod(newRevision, appspub.LifecycleStateNormal, true, false), // new creation }, - expectResult: expectationDiffs{deleteReadyLimit: 1}, + expectResult: expectationDiffs{deleteAvailableLimit: 1}, }, { name: "specified delete 2 pod (all ready) (step 5/6)", @@ -185,7 +185,7 @@ func TestCalculateDiffsWithExpectation(t *testing.T) { createTestPod(newRevision, appspub.LifecycleStateNormal, true, false), createTestPod(newRevision, appspub.LifecycleStateNormal, true, false), }, - expectResult: expectationDiffs{deleteReadyLimit: 2}, + expectResult: expectationDiffs{deleteAvailableLimit: 2}, }, { name: "specified delete 2 pod and replicas to 4 (step 2/3)", @@ -316,7 +316,7 @@ func TestCalculateDiffsWithExpectation(t *testing.T) { createTestPod(newRevision, appspub.LifecycleStateNormal, true, false), createTestPod(newRevision, appspub.LifecycleStateNormal, true, false), }, - expectResult: expectationDiffs{deleteReadyLimit: 1, useSurge: 1}, + expectResult: expectationDiffs{deleteAvailableLimit: 1, useSurge: 1}, }, { name: "specified delete with maxSurge (step 4/4)", @@ -366,7 +366,7 @@ func TestCalculateDiffsWithExpectation(t *testing.T) { createTestPod(newRevision, appspub.LifecycleStateUpdating, false, false), // new in-place update createTestPod(newRevision, appspub.LifecycleStateNormal, false, false), // new creation }, - expectResult: expectationDiffs{scaleDownNum: 1, scaleDownNumOldRevision: 1, deleteReadyLimit: 0}, + expectResult: expectationDiffs{scaleDownNum: 1, scaleDownNumOldRevision: 1, deleteAvailableLimit: 0}, }, { name: "update in-place partition=3 with maxSurge (step 4/4)", @@ -379,7 +379,7 @@ func TestCalculateDiffsWithExpectation(t *testing.T) { createTestPod(newRevision, appspub.LifecycleStateNormal, true, false), // new in-place update createTestPod(newRevision, appspub.LifecycleStateNormal, false, false), // new creation }, - expectResult: expectationDiffs{scaleDownNum: 1, scaleDownNumOldRevision: 1, deleteReadyLimit: 1}, + expectResult: expectationDiffs{scaleDownNum: 1, scaleDownNumOldRevision: 1, deleteAvailableLimit: 1}, }, { name: "update recreate partition=3 with maxSurge (step 1/7)", @@ -417,7 +417,7 @@ func TestCalculateDiffsWithExpectation(t *testing.T) { createTestPod(oldRevision, appspub.LifecycleStateNormal, true, true), // begin to recreate createTestPod(newRevision, appspub.LifecycleStateNormal, false, false), // new creation }, - expectResult: expectationDiffs{useSurge: 1, useSurgeOldRevision: 1, deleteReadyLimit: 1, updateNum: 1, updateMaxUnavailable: 2}, + expectResult: expectationDiffs{useSurge: 1, useSurgeOldRevision: 1, deleteAvailableLimit: 1, updateNum: 1, updateMaxUnavailable: 2}, }, { name: "update recreate partition=3 with maxSurge (step 4/7)", @@ -442,7 +442,7 @@ func TestCalculateDiffsWithExpectation(t *testing.T) { createTestPod(newRevision, appspub.LifecycleStateNormal, false, false), // new creation createTestPod(newRevision, appspub.LifecycleStateNormal, false, false), // new creation for update }, - expectResult: expectationDiffs{scaleDownNum: 1, scaleDownNumOldRevision: 1, deleteReadyLimit: 0}, + expectResult: expectationDiffs{scaleDownNum: 1, scaleDownNumOldRevision: 1, deleteAvailableLimit: 0}, }, { name: "update recreate partition=3 with maxSurge (step 6/7)", @@ -455,7 +455,7 @@ func TestCalculateDiffsWithExpectation(t *testing.T) { createTestPod(newRevision, appspub.LifecycleStateNormal, true, false), // new creation createTestPod(newRevision, appspub.LifecycleStateNormal, false, false), // new creation for update }, - expectResult: expectationDiffs{scaleDownNum: 1, scaleDownNumOldRevision: 1, deleteReadyLimit: 1}, + expectResult: expectationDiffs{scaleDownNum: 1, scaleDownNumOldRevision: 1, deleteAvailableLimit: 1}, }, { name: "update recreate partition=3 with maxSurge (step 7/7)", @@ -492,7 +492,7 @@ func TestCalculateDiffsWithExpectation(t *testing.T) { createTestPod(oldRevision, appspub.LifecycleStateNormal, true, false), createTestPod(newRevision, appspub.LifecycleStateNormal, false, false), // new creation }, - expectResult: expectationDiffs{scaleDownNum: 1, scaleDownNumOldRevision: 1, deleteReadyLimit: 3}, + expectResult: expectationDiffs{scaleDownNum: 1, scaleDownNumOldRevision: 1, deleteAvailableLimit: 3}, }, { name: "update recreate partition=99% with maxUnavailable=3, maxSurge=2 (step 3/3)", @@ -529,7 +529,7 @@ func TestCalculateDiffsWithExpectation(t *testing.T) { createTestPod(oldRevision, appspub.LifecycleStateNormal, true, false), createTestPod(newRevision, appspub.LifecycleStateNormal, false, false), // new creation }, - expectResult: expectationDiffs{scaleDownNum: 1, scaleDownNumOldRevision: 1, deleteReadyLimit: 2}, + expectResult: expectationDiffs{scaleDownNum: 1, scaleDownNumOldRevision: 1, deleteAvailableLimit: 2}, }, { name: "update recreate partition=99% with maxUnavailable=40%, maxSurge=30% (step 3/3)", @@ -566,7 +566,7 @@ func TestCalculateDiffsWithExpectation(t *testing.T) { createTestPod(oldRevision, appspub.LifecycleStateNormal, true, false), createTestPod(newRevision, appspub.LifecycleStateNormal, false, false), // new creation }, - expectResult: expectationDiffs{scaleDownNum: 1, scaleDownNumOldRevision: 1, deleteReadyLimit: 1}, + expectResult: expectationDiffs{scaleDownNum: 1, scaleDownNumOldRevision: 1, deleteAvailableLimit: 1}, }, { name: "update recreate partition=99% with maxUnavailable=30%, maxSurge=30% (step 3/3)", @@ -656,7 +656,7 @@ func TestCalculateDiffsWithExpectation(t *testing.T) { createTestPod(newRevision, appspub.LifecycleStateNormal, true, false), }, revisionConsistent: true, - expectResult: expectationDiffs{scaleDownNum: 1, scaleDownNumOldRevision: 2, deleteReadyLimit: 2, updateNum: 1, updateMaxUnavailable: 2}, + expectResult: expectationDiffs{scaleDownNum: 1, scaleDownNumOldRevision: 2, deleteAvailableLimit: 2, updateNum: 1, updateMaxUnavailable: 2}, }, { name: "disable rollback feature-gate", @@ -705,7 +705,7 @@ func TestCalculateDiffsWithExpectation(t *testing.T) { createTestPod(newRevision, appspub.LifecycleStateNormal, true, false), createTestPod(newRevision, appspub.LifecycleStateNormal, true, true), }, - expectResult: expectationDiffs{deleteReadyLimit: 1}, + expectResult: expectationDiffs{deleteAvailableLimit: 1}, }, { name: "[scalingExcludePreparingDelete=false] specific delete a pod with lifecycle hook (step 2/4)", @@ -745,7 +745,7 @@ func TestCalculateDiffsWithExpectation(t *testing.T) { createTestPod(newRevision, appspub.LifecycleStateNormal, true, false), createTestPod(newRevision, appspub.LifecycleStateNormal, true, true), }, - expectResult: expectationDiffs{deleteReadyLimit: 1}, + expectResult: expectationDiffs{deleteAvailableLimit: 1}, }, { name: "[scalingExcludePreparingDelete=true] specific delete a pod with lifecycle hook (step 2/4)", @@ -791,7 +791,7 @@ func TestCalculateDiffsWithExpectation(t *testing.T) { createTestPod(newRevision, appspub.LifecycleStateNormal, true, false), createTestPod(newRevision, appspub.LifecycleStateNormal, true, true), }, - expectResult: expectationDiffs{deleteReadyLimit: 1}, + expectResult: expectationDiffs{deleteAvailableLimit: 1}, }, { name: "[scalingExcludePreparingDelete=true] specific delete a pod with lifecycle hook and then cancel (step 2/5)", @@ -826,7 +826,7 @@ func TestCalculateDiffsWithExpectation(t *testing.T) { createTestPod(newRevision, appspub.LifecycleStateNormal, true, false), // it has been changed to normal by managePreparingDelete createTestPod(newRevision, appspub.LifecycleStateNormal, false, false), }, - expectResult: expectationDiffs{scaleDownNum: 1, deleteReadyLimit: 1}, + expectResult: expectationDiffs{scaleDownNum: 1, deleteAvailableLimit: 1}, }, { name: "[scalingExcludePreparingDelete=true] specific delete a pod with lifecycle hook and then cancel (step 5/5)", @@ -859,7 +859,7 @@ func TestCalculateDiffsWithExpectation(t *testing.T) { createTestPod(newRevision, appspub.LifecycleStateNormal, true, false), createTestPod(newRevision, appspub.LifecycleStateNormal, true, true), }, - expectResult: expectationDiffs{deleteReadyLimit: 2}, + expectResult: expectationDiffs{deleteAvailableLimit: 2}, }, { name: "[scalingExcludePreparingDelete=true] specific scale down with lifecycle hook, then scale up pods (step 3/6)", @@ -950,7 +950,7 @@ func TestCalculateDiffsWithExpectation(t *testing.T) { createTestPod(oldRevision, appspub.LifecycleStateNormal, true, false), createTestPod(oldRevision, appspub.LifecycleStateNormal, true, false), }, - expectResult: expectationDiffs{scaleDownNum: 2, scaleDownNumOldRevision: 5, deleteReadyLimit: 2, updateNum: 3, updateMaxUnavailable: 2}, + expectResult: expectationDiffs{scaleDownNum: 2, scaleDownNumOldRevision: 5, deleteAvailableLimit: 2, updateNum: 3, updateMaxUnavailable: 2}, }, { name: "[UpdateStrategyPaused=true] create 0 newRevision pods with maxSurge=3,maxUnavailable=0",