From ebf0014515a30b632fac7ea558327c0fbf5fb39e Mon Sep 17 00:00:00 2001 From: Carlos Tadeu Panato Junior Date: Thu, 28 Feb 2019 14:10:08 +0100 Subject: [PATCH] Add explicit deletion of pv and pvcs (#119) Signed-off-by: Carlos Panato --- pkg/tool/kubectl.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/tool/kubectl.go b/pkg/tool/kubectl.go index bd027f9..8c72765 100644 --- a/pkg/tool/kubectl.go +++ b/pkg/tool/kubectl.go @@ -23,6 +23,17 @@ func NewKubectl(exec exec.ProcessExecutor) Kubectl { // DeleteNamespace deletes the specified namespace. If the namespace does not terminate within 90s, pods running in the // namespace and, eventually, the namespace itself are force-deleted. func (k Kubectl) DeleteNamespace(namespace string) { + + fmt.Println("Deleting pvcs...") + if err := k.exec.RunProcess("kubectl", "delete", "pvc", "--namespace", namespace, "--all"); err != nil { + fmt.Println("Error deleting pvc(s):", err) + } + + fmt.Println("Deleting pvs...") + if err := k.exec.RunProcess("kubectl", "delete", "pv", "--namespace", namespace, "--all"); err != nil { + fmt.Println("Error deleting pv(s):", err) + } + fmt.Printf("Deleting namespace '%s'...\n", namespace) timeoutSec := "120s" if err := k.exec.RunProcess("kubectl", "delete", "namespace", namespace, "--timeout", timeoutSec); err != nil {