fix e2e delete namespace bug

pull/6/head
m1093782566 2016-11-03 19:55:46 +08:00
parent 3fe2de05ac
commit 0b62cc7f54
2 changed files with 8 additions and 2 deletions

View File

@ -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

View File

@ -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