mirror of https://github.com/k3s-io/k3s
delete replicaset when delete namespace
parent
62e574341c
commit
4f24ea65f2
|
@ -120,6 +120,7 @@ func testSyncNamespaceThatIsTerminating(t *testing.T, versions *unversioned.APIV
|
||||||
pendingActionSet.Insert(
|
pendingActionSet.Insert(
|
||||||
strings.Join([]string{"delete-collection", "daemonsets", ""}, "-"),
|
strings.Join([]string{"delete-collection", "daemonsets", ""}, "-"),
|
||||||
strings.Join([]string{"delete-collection", "deployments", ""}, "-"),
|
strings.Join([]string{"delete-collection", "deployments", ""}, "-"),
|
||||||
|
strings.Join([]string{"delete-collection", "replicasets", ""}, "-"),
|
||||||
strings.Join([]string{"delete-collection", "jobs", ""}, "-"),
|
strings.Join([]string{"delete-collection", "jobs", ""}, "-"),
|
||||||
strings.Join([]string{"delete-collection", "horizontalpodautoscalers", ""}, "-"),
|
strings.Join([]string{"delete-collection", "horizontalpodautoscalers", ""}, "-"),
|
||||||
strings.Join([]string{"delete-collection", "ingresses", ""}, "-"),
|
strings.Join([]string{"delete-collection", "ingresses", ""}, "-"),
|
||||||
|
@ -148,7 +149,7 @@ func testSyncNamespaceThatIsTerminating(t *testing.T, versions *unversioned.APIV
|
||||||
mockClient := fake.NewSimpleClientset(testInput.testNamespace)
|
mockClient := fake.NewSimpleClientset(testInput.testNamespace)
|
||||||
if containsVersion(versions, "extensions/v1beta1") {
|
if containsVersion(versions, "extensions/v1beta1") {
|
||||||
resources := []unversioned.APIResource{}
|
resources := []unversioned.APIResource{}
|
||||||
for _, resource := range []string{"daemonsets", "deployments", "jobs", "horizontalpodautoscalers", "ingresses"} {
|
for _, resource := range []string{"daemonsets", "deployments", "replicasets", "jobs", "horizontalpodautoscalers", "ingresses"} {
|
||||||
resources = append(resources, unversioned.APIResource{Name: resource})
|
resources = append(resources, unversioned.APIResource{Name: resource})
|
||||||
}
|
}
|
||||||
mockClient.Resources = map[string]*unversioned.APIResourceList{
|
mockClient.Resources = map[string]*unversioned.APIResourceList{
|
||||||
|
|
|
@ -184,6 +184,12 @@ func deleteAllContent(kubeClient clientset.Interface, versions *unversioned.APIV
|
||||||
return estimate, err
|
return estimate, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if containsResource(resources, "replicasets") {
|
||||||
|
err = deleteReplicaSets(kubeClient.Extensions(), namespace)
|
||||||
|
if err != nil {
|
||||||
|
return estimate, err
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return estimate, nil
|
return estimate, nil
|
||||||
}
|
}
|
||||||
|
@ -343,6 +349,10 @@ func deleteDeployments(expClient extensions_unversioned.ExtensionsInterface, ns
|
||||||
return expClient.Deployments(ns).DeleteCollection(nil, api.ListOptions{})
|
return expClient.Deployments(ns).DeleteCollection(nil, api.ListOptions{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func deleteReplicaSets(expClient extensions_unversioned.ExtensionsInterface, ns string) error {
|
||||||
|
return expClient.ReplicaSets(ns).DeleteCollection(nil, api.ListOptions{})
|
||||||
|
}
|
||||||
|
|
||||||
func deleteIngress(expClient extensions_unversioned.ExtensionsInterface, ns string) error {
|
func deleteIngress(expClient extensions_unversioned.ExtensionsInterface, ns string) error {
|
||||||
return expClient.Ingresses(ns).DeleteCollection(nil, api.ListOptions{})
|
return expClient.Ingresses(ns).DeleteCollection(nil, api.ListOptions{})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue