mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 15:37:24 +00:00
Updating federation namespace controller to share namespaced resources deletion code with kube namespace controller
This commit is contained in:
@@ -65,7 +65,7 @@ func TestFinalizeNamespaceFunc(t *testing.T) {
|
||||
Finalizers: []v1.FinalizerName{"kubernetes", "other"},
|
||||
},
|
||||
}
|
||||
d := NamespacedResourcesDeleter{
|
||||
d := namespacedResourcesDeleter{
|
||||
nsClient: mockClient.Core().Namespaces(),
|
||||
finalizerToken: v1.FinalizerKubernetes,
|
||||
}
|
||||
@@ -130,11 +130,6 @@ func testSyncNamespaceThatIsTerminating(t *testing.T, versions *metav1.APIVersio
|
||||
dynamicClientActionSet.Insert((&fakeAction{method: "GET", path: urlPath}).String())
|
||||
dynamicClientActionSet.Insert((&fakeAction{method: "DELETE", path: urlPath}).String())
|
||||
}
|
||||
// One additional GET for listing pods (to estimate graceful deletion).
|
||||
urlPath := path.Join([]string{
|
||||
dynamic.LegacyAPIPathResolverFunc(schema.GroupVersionKind{Group: "", Version: "v1"}),
|
||||
"", "v1", "namespaces", namespaceName}...)
|
||||
dynamicClientActionSet.Insert((&fakeAction{method: "GET", path: urlPath}).String())
|
||||
|
||||
scenarios := map[string]struct {
|
||||
testNamespace *v1.Namespace
|
||||
@@ -147,6 +142,7 @@ func testSyncNamespaceThatIsTerminating(t *testing.T, versions *metav1.APIVersio
|
||||
kubeClientActionSet: sets.NewString(
|
||||
strings.Join([]string{"get", "namespaces", ""}, "-"),
|
||||
strings.Join([]string{"create", "namespaces", "finalize"}, "-"),
|
||||
strings.Join([]string{"list", "pods", ""}, "-"),
|
||||
strings.Join([]string{"delete", "namespaces", ""}, "-"),
|
||||
),
|
||||
dynamicClientActionSet: dynamicClientActionSet,
|
||||
@@ -181,7 +177,7 @@ func testSyncNamespaceThatIsTerminating(t *testing.T, versions *metav1.APIVersio
|
||||
fn := func() ([]*metav1.APIResourceList, error) {
|
||||
return resources, nil
|
||||
}
|
||||
d := NewNamespacedResourcesDeleter(mockClient.Core().Namespaces(), clientPool, &OperationNotSupportedCache{M: make(map[OperationKey]bool)}, fn, v1.FinalizerKubernetes, true)
|
||||
d := NewNamespacedResourcesDeleter(mockClient.Core().Namespaces(), clientPool, mockClient.Core(), fn, v1.FinalizerKubernetes, true)
|
||||
err := d.Delete(testInput.testNamespace.Name)
|
||||
if err != nil {
|
||||
t.Errorf("scenario %s - Unexpected error when synching namespace %v", scenario, err)
|
||||
@@ -220,7 +216,7 @@ func TestRetryOnConflictError(t *testing.T) {
|
||||
return namespace, nil
|
||||
}
|
||||
namespace := &v1.Namespace{}
|
||||
d := NamespacedResourcesDeleter{
|
||||
d := namespacedResourcesDeleter{
|
||||
nsClient: mockClient.Core().Namespaces(),
|
||||
}
|
||||
_, err := d.retryOnConflictError(namespace, retryOnce)
|
||||
@@ -257,9 +253,8 @@ func TestSyncNamespaceThatIsActive(t *testing.T) {
|
||||
fn := func() ([]*metav1.APIResourceList, error) {
|
||||
return testResources(), nil
|
||||
}
|
||||
//err := syncNamespace(mockClient, nil, &operationNotSupportedCache{m: make(map[operationKey]bool)}, fn, testNamespace, v1.FinalizerKubernetes)
|
||||
d := NewNamespacedResourcesDeleter(mockClient.Core().Namespaces(), nil,
|
||||
&OperationNotSupportedCache{M: make(map[OperationKey]bool)}, fn, v1.FinalizerKubernetes, true)
|
||||
d := NewNamespacedResourcesDeleter(mockClient.Core().Namespaces(), nil, mockClient.Core(),
|
||||
fn, v1.FinalizerKubernetes, true)
|
||||
err := d.Delete(testNamespace.Name)
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error when synching namespace %v", err)
|
||||
|
||||
Reference in New Issue
Block a user