Commit a2bf827e authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #36154 from m1093782566/m109-fix-del-ns

Automatic merge from submit-queue fix e2e delete namespace bug <!-- Thanks for sending a pull request! Here are some tips for you: 1. If this is your first time, read our contributor guidelines https://github.com/kubernetes/kubernetes/blob/master/CONTRIBUTING.md and developer guide https://github.com/kubernetes/kubernetes/blob/master/docs/devel/development.md 2. If you want *faster* PR reviews, read how: https://github.com/kubernetes/kubernetes/blob/master/docs/devel/faster_reviews.md 3. Follow the instructions for writing a release note: https://github.com/kubernetes/kubernetes/blob/master/docs/devel/pull-requests.md#release-notes --> **What:** Fix `CreateNamespace()` bug in `test/e2e/framework/framework.go`. **Why:** If we successfully create a namespace but fail to create a ServiceAccount in it, we should delete the namespace after test. The current implement of `CreateNamespace()` int e2e test will forget to delete the namespace which we fail to create serviceAccount in it(but the namespace has been successfully created!).
parents c6191126 0b62cc7f
...@@ -445,7 +445,10 @@ func (f *Framework) CreateNamespace(baseName string, labels map[string]string) ( ...@@ -445,7 +445,10 @@ func (f *Framework) CreateNamespace(baseName string, labels map[string]string) (
createTestingNS = CreateTestingNS createTestingNS = CreateTestingNS
} }
ns, err := createTestingNS(baseName, f.ClientSet, labels) 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) f.namespacesToDelete = append(f.namespacesToDelete, ns)
} }
return ns, err return ns, err
......
...@@ -916,7 +916,10 @@ func CreateTestingNS(baseName string, c clientset.Interface, labels map[string]s ...@@ -916,7 +916,10 @@ func CreateTestingNS(baseName string, c clientset.Interface, labels map[string]s
if TestContext.VerifyServiceAccount { if TestContext.VerifyServiceAccount {
if err := WaitForDefaultServiceAccountInNamespace(c, got.Name); err != nil { 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 return got, nil
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment