From 0b62cc7f5415f57a744b27c4b6fccf3b49906726 Mon Sep 17 00:00:00 2001 From: m1093782566 Date: Thu, 3 Nov 2016 19:55:46 +0800 Subject: [PATCH] fix e2e delete namespace bug --- test/e2e/framework/framework.go | 5 ++++- test/e2e/framework/util.go | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/test/e2e/framework/framework.go b/test/e2e/framework/framework.go index d557d2d9614..bbede98aab1 100644 --- a/test/e2e/framework/framework.go +++ b/test/e2e/framework/framework.go @@ -445,7 +445,10 @@ func (f *Framework) CreateNamespace(baseName string, labels map[string]string) ( createTestingNS = CreateTestingNS } ns, err := createTestingNS(baseName, f.ClientSet, labels) - if err == nil { + // check ns instead of err to see if it's nil as we may + // fail to create serviceAccount in it. + // In this case, we should not forget to delete the namespace. + if ns != nil { f.namespacesToDelete = append(f.namespacesToDelete, ns) } return ns, err diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index d6a12f7ed5a..fc9877676a8 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -912,7 +912,10 @@ func CreateTestingNS(baseName string, c clientset.Interface, labels map[string]s if TestContext.VerifyServiceAccount { if err := WaitForDefaultServiceAccountInNamespace(c, got.Name); err != nil { - return nil, err + // Even if we fail to create serviceAccount in the namespace, + // we have successfully create a namespace. + // So, return the created namespace. + return got, err } } return got, nil