mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 09:52:49 +00:00
fix kubectl wait --for=delete ignore not found
Signed-off-by: Ling Samuel <lingsamuelgrace@gmail.com>
This commit is contained in:
parent
d20e3246ba
commit
99cdc37e2a
@ -247,7 +247,8 @@ func (o *WaitOptions) RunWait() error {
|
||||
return err
|
||||
}
|
||||
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)
|
||||
}
|
||||
|
||||
@ -255,7 +256,7 @@ func (o *WaitOptions) RunWait() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if visitCount == 0 {
|
||||
if visitCount == 0 && !isForDelete {
|
||||
return errNoMatchingResources
|
||||
}
|
||||
return err
|
||||
|
@ -801,15 +801,7 @@ func TestWaitForDeletionIgnoreNotFound(t *testing.T) {
|
||||
listMapping := map[schema.GroupVersionResource]string{
|
||||
{Group: "group", Version: "version", Resource: "theresource"}: "TheKindList",
|
||||
}
|
||||
infos := []*resource.Info{
|
||||
{
|
||||
Mapping: &meta.RESTMapping{
|
||||
Resource: schema.GroupVersionResource{Group: "group", Version: "version", Resource: "theresource"},
|
||||
},
|
||||
Name: "name-foo",
|
||||
Namespace: "ns-foo",
|
||||
},
|
||||
}
|
||||
infos := []*resource.Info{}
|
||||
fakeClient := dynamicfakeclient.NewSimpleDynamicClientWithCustomListKinds(scheme, listMapping)
|
||||
|
||||
o := &WaitOptions{
|
||||
|
@ -1827,6 +1827,14 @@ metadata:
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
ginkgo.Describe("kubectl wait", func() {
|
||||
ginkgo.It("should ignore not found error with --for=delete", func() {
|
||||
ginkgo.By("calling kubectl wait --for=delete")
|
||||
framework.RunKubectlOrDie(ns, "wait", "--for=delete", "pod/doesnotexist")
|
||||
framework.RunKubectlOrDie(ns, "wait", "--for=delete", "pod", "--selector=app.kubernetes.io/name=noexist")
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
// Checks whether the output split by line contains the required elements.
|
||||
|
Loading…
Reference in New Issue
Block a user