mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 04:06:03 +00:00
Merge pull request #46037 from ncdc/ns-controller-aggregate-errors
Automatic merge from submit-queue (batch tested with PRs 46164, 45471, 46037) NS controller: don't stop deleting GVRs on error **What this PR does / why we need it**: If the namespace controller encounters an error trying to delete a single GroupVersionResource, add the error to an aggregated list of errors and continue attempting to delete all the GroupVersionResources instead of stopping at the first error. Return the aggregated error list (if any) when done. This allows us to delete as much of the content in the namespace as we can in each pass. **Special notes for your reviewer**: This may help with some of the namespace deletions taking too long in our e2e tests. **Release note**: ```release-note ```
This commit is contained in:
commit
16b5093feb
@ -20,6 +20,7 @@ go_library(
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/errors:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
|
||||
"//vendor/k8s.io/client-go/discovery:go_default_library",
|
||||
"//vendor/k8s.io/client-go/dynamic:go_default_library",
|
||||
|
@ -28,11 +28,11 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
utilerrors "k8s.io/apimachinery/pkg/util/errors"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/kubernetes/pkg/api/v1"
|
||||
// "k8s.io/kubernetes/pkg/client/clientset_generated/clientset"
|
||||
"k8s.io/client-go/discovery"
|
||||
"k8s.io/client-go/dynamic"
|
||||
"k8s.io/kubernetes/pkg/api/v1"
|
||||
v1clientset "k8s.io/kubernetes/pkg/client/clientset_generated/clientset/typed/core/v1"
|
||||
)
|
||||
|
||||
@ -504,15 +504,21 @@ func (d *namespacedResourcesDeleter) deleteAllContent(
|
||||
if err != nil {
|
||||
return estimate, err
|
||||
}
|
||||
var errs []error
|
||||
for gvr := range groupVersionResources {
|
||||
gvrEstimate, err := d.deleteAllContentForGroupVersionResource(gvr, namespace, namespaceDeletedAt)
|
||||
if err != nil {
|
||||
return estimate, err
|
||||
// If there is an error, hold on to it but proceed with all the remaining
|
||||
// groupVersionResources.
|
||||
errs = append(errs, err)
|
||||
}
|
||||
if gvrEstimate > estimate {
|
||||
estimate = gvrEstimate
|
||||
}
|
||||
}
|
||||
if len(errs) > 0 {
|
||||
return estimate, utilerrors.NewAggregate(errs)
|
||||
}
|
||||
glog.V(4).Infof("namespace controller - deleteAllContent - namespace: %s, estimate: %v", namespace, estimate)
|
||||
return estimate, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user