Define constant for eviction failure cause

This commit is contained in:
Jordan Liggitt
2021-04-14 09:12:21 -04:00
parent f07fc213b0
commit 10b07085f8
3 changed files with 11 additions and 6 deletions

View File

@@ -23,7 +23,6 @@ import (
jsonpatch "github.com/evanphx/json-patch"
"github.com/onsi/ginkgo"
"github.com/onsi/gomega"
appsv1 "k8s.io/api/apps/v1"
v1 "k8s.io/api/core/v1"
@@ -293,7 +292,8 @@ var _ = SIGDescribe("DisruptionController", func() {
if c.shouldDeny {
err = cs.CoreV1().Pods(ns).EvictV1(context.TODO(), e)
gomega.Expect(err).Should(gomega.MatchError("Cannot evict pod as it would violate the pod's disruption budget."))
framework.ExpectError(err, "pod eviction should fail")
framework.ExpectEqual(apierrors.HasStatusCause(err, policyv1.DisruptionBudgetCause), true, "pod eviction should fail with DisruptionBudget cause")
} else {
// Only wait for running pods in the "allow" case
// because one of shouldDeny cases relies on the
@@ -331,7 +331,8 @@ var _ = SIGDescribe("DisruptionController", func() {
},
}
err = cs.CoreV1().Pods(ns).EvictV1(context.TODO(), e)
gomega.Expect(err).Should(gomega.MatchError("Cannot evict pod as it would violate the pod's disruption budget."))
framework.ExpectError(err, "pod eviction should fail")
framework.ExpectEqual(apierrors.HasStatusCause(err, policyv1.DisruptionBudgetCause), true, "pod eviction should fail with DisruptionBudget cause")
ginkgo.By("Updating the pdb to allow a pod to be evicted")
updatePDBOrDie(cs, ns, defaultName, func(pdb *policyv1.PodDisruptionBudget) *policyv1.PodDisruptionBudget {
@@ -368,7 +369,8 @@ var _ = SIGDescribe("DisruptionController", func() {
},
}
err = cs.CoreV1().Pods(ns).EvictV1(context.TODO(), e)
gomega.Expect(err).Should(gomega.MatchError("Cannot evict pod as it would violate the pod's disruption budget."))
framework.ExpectError(err, "pod eviction should fail")
framework.ExpectEqual(apierrors.HasStatusCause(err, policyv1.DisruptionBudgetCause), true, "pod eviction should fail with DisruptionBudget cause")
ginkgo.By("Deleting the pdb to allow a pod to be evicted")
deletePDBOrDie(cs, ns, defaultName)