Unverified Commit 585af4a2 authored by Jingfang Liu's avatar Jingfang Liu Committed by Maciej Szulik

Add retry to AssertCleanup

parent 3ec04f8d
...@@ -2079,15 +2079,32 @@ func AssertCleanup(ns string, selectors ...string) { ...@@ -2079,15 +2079,32 @@ func AssertCleanup(ns string, selectors ...string) {
if ns != "" { if ns != "" {
nsArg = fmt.Sprintf("--namespace=%s", ns) nsArg = fmt.Sprintf("--namespace=%s", ns)
} }
for _, selector := range selectors {
resources := RunKubectlOrDie("get", "rc,svc", "-l", selector, "--no-headers", nsArg) backoff := wait.Backoff{
if resources != "" { Duration: 5 * time.Second,
Failf("Resources left running after stop:\n%s", resources) Factor: 2,
} Steps: 3,
pods := RunKubectlOrDie("get", "pods", "-l", selector, nsArg, "-o", "go-template={{ range .items }}{{ if not .metadata.deletionTimestamp }}{{ .metadata.name }}{{ \"\\n\" }}{{ end }}{{ end }}") }
if pods != "" { var e error
Failf("Pods left unterminated after stop:\n%s", pods) verifyCleanupFunc := func() (bool, error) {
e = nil
for _, selector := range selectors {
resources := RunKubectlOrDie("get", "rc,svc", "-l", selector, "--no-headers", nsArg)
if resources != "" {
e = fmt.Errorf("Resources left running after stop:\n%s", resources)
return false, nil
}
pods := RunKubectlOrDie("get", "pods", "-l", selector, nsArg, "-o", "go-template={{ range .items }}{{ if not .metadata.deletionTimestamp }}{{ .metadata.name }}{{ \"\\n\" }}{{ end }}{{ end }}")
if pods != "" {
e = fmt.Errorf("Pods left unterminated after stop:\n%s", pods)
return false, nil
}
} }
return true, nil
}
err := wait.ExponentialBackoff(backoff, verifyCleanupFunc)
if err != nil {
Failf(e.Error())
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment