skip finalizer validation (#1815)

add some time to check cloneset replicas

fix flaky test
This commit is contained in:
wyike
2021-06-18 14:36:40 +08:00
committed by GitHub
parent 70eeec4c89
commit b752511e74
2 changed files with 32 additions and 0 deletions

View File

@@ -52,6 +52,12 @@ func (h *ValidatingHandler) Handle(ctx context.Context, req admission.Request) a
return admission.Errored(http.StatusBadRequest, err)
}
// there is no need validate deleted rollout, th
if !obj.DeletionTimestamp.IsZero() {
klog.InfoS("skip validate deleted rollout ", "namespace", obj.Namespace, "name", obj.Name)
return admission.ValidationResponse(true, "")
}
switch req.AdmissionRequest.Operation {
case admissionv1beta1.Create:
if allErrs := h.ValidateCreate(obj); len(allErrs) > 0 {

View File

@@ -729,6 +729,19 @@ var _ = Describe("Cloneset based rollout tests", func() {
}
return nil
}, 60*time.Second, 300*time.Microsecond).Should(BeNil())
// before check status, we must guarantee the cloneset has been update
Eventually(func() error {
clonesetName := appRollout.Spec.ComponentList[0]
kc = kruise.CloneSet{}
err := k8sClient.Get(ctx, client.ObjectKey{Namespace: namespaceName, Name: clonesetName}, &kc)
if err != nil {
return err
}
if *kc.Spec.Replicas != 5 {
return fmt.Errorf("pod replicas mismatch")
}
return nil
}, 30*time.Second, 300*time.Microsecond).Should(BeNil())
verifyRolloutSucceeded(appRollout.Spec.TargetAppRevisionName)
By("modify appRollout targetSize to 7")
Eventually(func() error {
@@ -741,6 +754,19 @@ var _ = Describe("Cloneset based rollout tests", func() {
}
return nil
}, 60*time.Second, 300*time.Microsecond).Should(BeNil())
// before check status, we must guarantee the cloneset has been update
Eventually(func() error {
kc = kruise.CloneSet{}
clonesetName := appRollout.Spec.ComponentList[0]
err := k8sClient.Get(ctx, client.ObjectKey{Namespace: namespaceName, Name: clonesetName}, &kc)
if err != nil {
return err
}
if *kc.Spec.Replicas != 7 {
return fmt.Errorf("pod replicas mismatch")
}
return nil
}, 30*time.Second, 300*time.Microsecond).Should(BeNil())
verifyRolloutSucceeded(appRollout.Spec.TargetAppRevisionName)
})