forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploymentconfigs.go
47 lines (40 loc) · 1.29 KB
/
deploymentconfigs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package util
import (
"time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kutilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/apimachinery/pkg/util/wait"
e2e "k8s.io/kubernetes/test/e2e/framework"
)
// RemoveDeploymentConfigs deletes the given DeploymentConfigs in a namespace
func RemoveDeploymentConfigs(oc *CLI, dcs ...string) error {
errs := []error{}
for _, dc := range dcs {
e2e.Logf("Removing deployment config %s/%s", oc.Namespace(), dc)
if err := oc.AdminAppsClient().Apps().DeploymentConfigs(oc.Namespace()).Delete(dc, &metav1.DeleteOptions{}); err != nil {
e2e.Logf("Error occurred removing deployment config: %v", err)
errs = append(errs, err)
}
err := wait.PollImmediate(5*time.Second, 5*time.Minute, func() (bool, error) {
pods, err := GetApplicationPods(oc, dc)
if err != nil {
e2e.Logf("Unable to get pods for dc/%s: %v", dc, err)
return false, err
}
if len(pods.Items) > 0 {
e2e.Logf("Waiting for pods for dc/%s to terminate", dc)
return false, nil
}
e2e.Logf("Pods for dc/%s have terminated", dc)
return true, nil
})
if err != nil {
e2e.Logf("Error occurred waiting for pods to terminate for dc/%s: %v", dc, err)
errs = append(errs, err)
}
}
if len(errs) != 0 {
return kutilerrors.NewAggregate(errs)
}
return nil
}