mirror of https://github.com/k3s-io/k3s
Merge pull request #65367 from deads2k/cli-77-delete
Automatic merge from submit-queue (batch tested with PRs 65339, 65343, 65324, 65335, 65367). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. make sure delete waiting doesn't re-evaluate the resource lists Fixes https://github.com/kubernetes/kubernetes/issues/65366 ```release-note Prevents a `kubectl delete` hang when deleting controller managed lists ``` @kubernetes/sig-cli-maintainerspull/8/head
commit
eb5a26f801
|
@ -234,10 +234,12 @@ func (o *DeleteOptions) DeleteResult(r *resource.Result) error {
|
||||||
if o.IgnoreNotFound {
|
if o.IgnoreNotFound {
|
||||||
r = r.IgnoreErrors(errors.IsNotFound)
|
r = r.IgnoreErrors(errors.IsNotFound)
|
||||||
}
|
}
|
||||||
|
deletedInfos := []*resource.Info{}
|
||||||
err := r.Visit(func(info *resource.Info, err error) error {
|
err := r.Visit(func(info *resource.Info, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
deletedInfos = append(deletedInfos, info)
|
||||||
found++
|
found++
|
||||||
|
|
||||||
options := &metav1.DeleteOptions{}
|
options := &metav1.DeleteOptions{}
|
||||||
|
@ -249,6 +251,7 @@ func (o *DeleteOptions) DeleteResult(r *resource.Result) error {
|
||||||
policy = metav1.DeletePropagationOrphan
|
policy = metav1.DeletePropagationOrphan
|
||||||
}
|
}
|
||||||
options.PropagationPolicy = &policy
|
options.PropagationPolicy = &policy
|
||||||
|
|
||||||
return o.deleteResource(info, options)
|
return o.deleteResource(info, options)
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -273,7 +276,7 @@ func (o *DeleteOptions) DeleteResult(r *resource.Result) error {
|
||||||
effectiveTimeout = 168 * time.Hour
|
effectiveTimeout = 168 * time.Hour
|
||||||
}
|
}
|
||||||
waitOptions := kubectlwait.WaitOptions{
|
waitOptions := kubectlwait.WaitOptions{
|
||||||
ResourceFinder: genericclioptions.ResourceFinderForResult(r),
|
ResourceFinder: genericclioptions.ResourceFinderForResult(resource.InfoListVisitor(deletedInfos)),
|
||||||
DynamicClient: o.DynamicClient,
|
DynamicClient: o.DynamicClient,
|
||||||
Timeout: effectiveTimeout,
|
Timeout: effectiveTimeout,
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue