Merge pull request #31925 from nikhiljindal/freshDebugNs

Automatic merge from submit-queue

Adding namespaces/finalizer subresource to federation apiserver

Fixes https://github.com/kubernetes/kubernetes/issues/31077

cc @kubernetes/sig-cluster-federation @mwielgus 


Verified manually that I can delete federation namespaces now.
Will update federation-namespace e2e test to verify that namespace is deleted fine
This commit is contained in:
Kubernetes Submit Queue
2016-09-02 19:30:25 -07:00
committed by GitHub
6 changed files with 84 additions and 28 deletions

View File

@@ -54,16 +54,13 @@ var _ = framework.KubeDescribe("Federation namespace [Feature:Federation]", func
AfterEach(func() {
framework.SkipUnlessFederated(f.Client)
// TODO: set wait to true once NS controller is fixed.
deleteAllTestNamespaces(
f.FederationClientset_1_4.Core().Namespaces().List,
f.FederationClientset_1_4.Core().Namespaces().Delete,
false)
f.FederationClientset_1_4.Core().Namespaces().Delete)
for _, clientset := range clusterClientSet {
deleteAllTestNamespaces(
clientset.Core().Namespaces().List,
clientset.Core().Namespaces().Delete,
false)
clientset.Core().Namespaces().Delete)
}
})
@@ -79,7 +76,7 @@ var _ = framework.KubeDescribe("Federation namespace [Feature:Federation]", func
_, err := f.FederationClientset_1_4.Core().Namespaces().Create(&ns)
framework.ExpectNoError(err, "Failed to create namespace %s", ns.Name)
// Check subclusters if the namespace was create there.
// Check subclusters if the namespace was created there.
err = wait.Poll(5*time.Second, 2*time.Minute, func() (bool, error) {
for _, client := range clusterClientSet {
_, err := client.Core().Namespaces().Get(ns.Name)
@@ -94,32 +91,28 @@ var _ = framework.KubeDescribe("Federation namespace [Feature:Federation]", func
})
framework.ExpectNoError(err, "Not all namespaces created")
// TODO: set wait to true once NS controller is fixed.
deleteAllTestNamespaces(
f.FederationClientset_1_4.Core().Namespaces().List,
f.FederationClientset_1_4.Core().Namespaces().Delete,
false)
f.FederationClientset_1_4.Core().Namespaces().Delete)
})
})
})
func deleteAllTestNamespaces(lister func(api.ListOptions) (*api_v1.NamespaceList, error), deleter func(string, *api.DeleteOptions) error, waitForDeletion bool) {
func deleteAllTestNamespaces(lister func(api.ListOptions) (*api_v1.NamespaceList, error), deleter func(string, *api.DeleteOptions) error) {
list, err := lister(api.ListOptions{})
if err != nil {
framework.Failf("Failed to get all namespaes: %v", err)
return
}
for _, namespace := range list.Items {
if strings.HasPrefix(namespace.Name, namespacePrefix) && namespace.DeletionTimestamp != nil {
if strings.HasPrefix(namespace.Name, namespacePrefix) {
err := deleter(namespace.Name, &api.DeleteOptions{})
if err != nil {
framework.Failf("Failed to set %s for deletion: %v", namespace.Name, err)
}
}
}
if waitForDeletion {
waitForNoTestNamespaces(lister)
}
waitForNoTestNamespaces(lister)
}
func waitForNoTestNamespaces(lister func(api.ListOptions) (*api_v1.NamespaceList, error)) {

View File

@@ -283,8 +283,8 @@ func testCoreResourceList(t *testing.T) {
}
assert.Equal(t, "", apiResourceList.APIVersion)
assert.Equal(t, v1.SchemeGroupVersion.String(), apiResourceList.GroupVersion)
// Assert that there are exactly 6 resources.
assert.Equal(t, 6, len(apiResourceList.APIResources))
// Assert that there are exactly 7 resources.
assert.Equal(t, 7, len(apiResourceList.APIResources))
// Verify services.
found := findResource(apiResourceList.APIResources, "services")
@@ -301,6 +301,9 @@ func testCoreResourceList(t *testing.T) {
found = findResource(apiResourceList.APIResources, "namespaces/status")
assert.NotNil(t, found)
assert.False(t, found.Namespaced)
found = findResource(apiResourceList.APIResources, "namespaces/finalize")
assert.NotNil(t, found)
assert.False(t, found.Namespaced)
// Verify events.
found = findResource(apiResourceList.APIResources, "events")