Просмотр исходного кода

case for a Terminating namespace for deletion

Mohammed Nafees 3 лет назад
Родитель
Сommit
97961280b3
1 измененных файлов с 7 добавлено и 1 удалено
  1. 7 1
      internal/kubernetes/agent.go

+ 7 - 1
internal/kubernetes/agent.go

@@ -690,7 +690,7 @@ func (a *Agent) GetNamespace(name string) (*v1.Namespace, error) {
 // DeleteNamespace deletes the namespace given the name.
 func (a *Agent) DeleteNamespace(name string) error {
 	// check if namespace exists
-	_, err := a.Clientset.CoreV1().Namespaces().Get(
+	checkNS, err := a.Clientset.CoreV1().Namespaces().Get(
 		context.TODO(),
 		name,
 		metav1.GetOptions{},
@@ -701,6 +701,12 @@ func (a *Agent) DeleteNamespace(name string) error {
 		return nil
 	}
 
+	// if the namespace was found but is in the "Terminating" phase
+	// we should ignore it and not return an error
+	if checkNS != nil && checkNS.Status.Phase == v1.NamespaceTerminating {
+		return nil
+	}
+
 	return a.Clientset.CoreV1().Namespaces().Delete(
 		context.TODO(),
 		name,