fix kubectl wait --for=delete ignore not found

Signed-off-by: Ling Samuel <lingsamuelgrace@gmail.com>

Kubernetes-commit: 99cdc37e2a89df1f86045f295916c00266e4d034
This commit is contained in:
Ling Samuel 2020-11-19 14:48:28 +08:00 committed by Kubernetes Publisher
parent c45ce3e811
commit cf01e4558b
2 changed files with 4 additions and 11 deletions

View File

@ -249,7 +249,8 @@ func (o *WaitOptions) RunWait() error {
return err return err
} }
visitor := o.ResourceFinder.Do() visitor := o.ResourceFinder.Do()
if visitor, ok := visitor.(*resource.Result); ok && strings.ToLower(o.ForCondition) == "delete" { isForDelete := strings.ToLower(o.ForCondition) == "delete"
if visitor, ok := visitor.(*resource.Result); ok && isForDelete {
visitor.IgnoreErrors(apierrors.IsNotFound) visitor.IgnoreErrors(apierrors.IsNotFound)
} }
@ -257,7 +258,7 @@ func (o *WaitOptions) RunWait() error {
if err != nil { if err != nil {
return err return err
} }
if visitCount == 0 { if visitCount == 0 && !isForDelete {
return errNoMatchingResources return errNoMatchingResources
} }
return err return err

View File

@ -985,15 +985,7 @@ func TestWaitForDeletionIgnoreNotFound(t *testing.T) {
listMapping := map[schema.GroupVersionResource]string{ listMapping := map[schema.GroupVersionResource]string{
{Group: "group", Version: "version", Resource: "theresource"}: "TheKindList", {Group: "group", Version: "version", Resource: "theresource"}: "TheKindList",
} }
infos := []*resource.Info{ infos := []*resource.Info{}
{
Mapping: &meta.RESTMapping{
Resource: schema.GroupVersionResource{Group: "group", Version: "version", Resource: "theresource"},
},
Name: "name-foo",
Namespace: "ns-foo",
},
}
fakeClient := dynamicfakeclient.NewSimpleDynamicClientWithCustomListKinds(scheme, listMapping) fakeClient := dynamicfakeclient.NewSimpleDynamicClientWithCustomListKinds(scheme, listMapping)
o := &WaitOptions{ o := &WaitOptions{