mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 09:52:49 +00:00
Merge pull request #96702 from lingsamuel/wait-for-delete-ignore-not-found
Fix `kubectl wait --for=delete` ignore not found
This commit is contained in:
commit
c05810cc5d
@ -249,7 +249,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)
|
||||
}
|
||||
|
||||
@ -257,7 +258,7 @@ func (o *WaitOptions) RunWait() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if visitCount == 0 {
|
||||
if visitCount == 0 && !isForDelete {
|
||||
return errNoMatchingResources
|
||||
}
|
||||
return err
|
||||
|
@ -985,15 +985,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{
|
||||
|
@ -1831,6 +1831,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