Skip to content

Commit

Permalink
Merge pull request #64400 from soltysh/fix_kubecl_rc
Browse files Browse the repository at this point in the history
Automatic merge from submit-queue.

Add retry to AssertCleanup

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
This addresses the other two problems mentioned in #64362 by cherry-picking #61565 and #62155 on to 1.10 release. 

**Release note**:
```release-note
NONE
```
  • Loading branch information
Kubernetes Submit Queue committed May 28, 2018
2 parents 04209a9 + 8819dee commit c5f46f9
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions test/e2e/framework/util.go
Expand Up @@ -2079,15 +2079,27 @@ func AssertCleanup(ns string, selectors ...string) {
if ns != "" {
nsArg = fmt.Sprintf("--namespace=%s", ns)
}
for _, selector := range selectors {
resources := RunKubectlOrDie("get", "rc,svc", "-l", selector, "--no-headers", nsArg)
if resources != "" {
Failf("Resources left running after stop:\n%s", resources)
}
pods := RunKubectlOrDie("get", "pods", "-l", selector, nsArg, "-o", "go-template={{ range .items }}{{ if not .metadata.deletionTimestamp }}{{ .metadata.name }}{{ \"\\n\" }}{{ end }}{{ end }}")
if pods != "" {
Failf("Pods left unterminated after stop:\n%s", pods)

var e error
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.PollImmediate(500*time.Millisecond, 1*time.Minute, verifyCleanupFunc)
if err != nil {
Failf(e.Error())
}
}

Expand Down

0 comments on commit c5f46f9

Please sign in to comment.