-
Notifications
You must be signed in to change notification settings - Fork 114
/
Copy pathclean.go
41 lines (34 loc) · 1.13 KB
/
clean.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
package clean
import (
"fmt"
"os"
"time"
"github.com/k8snetworkplumbingwg/sriov-network-operator/test/util/client"
"github.com/k8snetworkplumbingwg/sriov-network-operator/test/util/cluster"
"github.com/k8snetworkplumbingwg/sriov-network-operator/test/util/namespaces"
)
var RestoreNodeDrainState bool
// All cleans all the dangling resources created by conformance tests.
// This includes pods, networks, policies and namespaces.
func All() error {
operatorNamespace, found := os.LookupEnv("OPERATOR_NAMESPACE")
if !found {
operatorNamespace = "openshift-sriov-network-operator"
}
clients := client.New("")
if RestoreNodeDrainState {
err := cluster.SetDisableNodeDrainState(clients, operatorNamespace, false)
if err != nil {
return fmt.Errorf("failed to restore node drain state %v", err)
}
}
err := namespaces.DeleteAndWait(clients, namespaces.Test, 5*time.Minute)
if err != nil {
return fmt.Errorf("failed to delete sriov tests namespace %v", err)
}
err = namespaces.Clean(operatorNamespace, namespaces.Test, clients, false)
if err != nil {
return fmt.Errorf("failed to clean sriov resources %v", err)
}
return nil
}