mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Added resource name to timeout error output on WAIT cmd
This commit is contained in:
parent
d654b49c0e
commit
892f15d9a2
@ -51,7 +51,6 @@ go_test(
|
|||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/util/wait:go_default_library",
|
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/watch:go_default_library",
|
||||||
"//staging/src/k8s.io/cli-runtime/pkg/genericclioptions:go_default_library",
|
"//staging/src/k8s.io/cli-runtime/pkg/genericclioptions:go_default_library",
|
||||||
"//staging/src/k8s.io/cli-runtime/pkg/genericclioptions/printers:go_default_library",
|
"//staging/src/k8s.io/cli-runtime/pkg/genericclioptions/printers:go_default_library",
|
||||||
|
@ -292,9 +292,10 @@ func IsDeleted(info *resource.Info, o *WaitOptions) (runtime.Object, bool, error
|
|||||||
}
|
}
|
||||||
|
|
||||||
timeout := endTime.Sub(time.Now())
|
timeout := endTime.Sub(time.Now())
|
||||||
|
errWaitTimeoutWithName := extendErrWaitTimeout(wait.ErrWaitTimeout, info)
|
||||||
if timeout < 0 {
|
if timeout < 0 {
|
||||||
// we're out of time
|
// we're out of time
|
||||||
return gottenObj, false, wait.ErrWaitTimeout
|
return gottenObj, false, errWaitTimeoutWithName
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := watchtools.ContextWithOptionalTimeout(context.Background(), o.Timeout)
|
ctx, cancel := watchtools.ContextWithOptionalTimeout(context.Background(), o.Timeout)
|
||||||
@ -307,9 +308,9 @@ func IsDeleted(info *resource.Info, o *WaitOptions) (runtime.Object, bool, error
|
|||||||
continue
|
continue
|
||||||
case err == wait.ErrWaitTimeout:
|
case err == wait.ErrWaitTimeout:
|
||||||
if watchEvent != nil {
|
if watchEvent != nil {
|
||||||
return watchEvent.Object, false, wait.ErrWaitTimeout
|
return watchEvent.Object, false, errWaitTimeoutWithName
|
||||||
}
|
}
|
||||||
return gottenObj, false, wait.ErrWaitTimeout
|
return gottenObj, false, errWaitTimeoutWithName
|
||||||
default:
|
default:
|
||||||
return gottenObj, false, err
|
return gottenObj, false, err
|
||||||
}
|
}
|
||||||
@ -386,9 +387,10 @@ func (w ConditionalWait) IsConditionMet(info *resource.Info, o *WaitOptions) (ru
|
|||||||
}
|
}
|
||||||
|
|
||||||
timeout := endTime.Sub(time.Now())
|
timeout := endTime.Sub(time.Now())
|
||||||
|
errWaitTimeoutWithName := extendErrWaitTimeout(wait.ErrWaitTimeout, info)
|
||||||
if timeout < 0 {
|
if timeout < 0 {
|
||||||
// we're out of time
|
// we're out of time
|
||||||
return gottenObj, false, wait.ErrWaitTimeout
|
return gottenObj, false, errWaitTimeoutWithName
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx, cancel := watchtools.ContextWithOptionalTimeout(context.Background(), o.Timeout)
|
ctx, cancel := watchtools.ContextWithOptionalTimeout(context.Background(), o.Timeout)
|
||||||
@ -401,9 +403,9 @@ func (w ConditionalWait) IsConditionMet(info *resource.Info, o *WaitOptions) (ru
|
|||||||
continue
|
continue
|
||||||
case err == wait.ErrWaitTimeout:
|
case err == wait.ErrWaitTimeout:
|
||||||
if watchEvent != nil {
|
if watchEvent != nil {
|
||||||
return watchEvent.Object, false, wait.ErrWaitTimeout
|
return watchEvent.Object, false, errWaitTimeoutWithName
|
||||||
}
|
}
|
||||||
return gottenObj, false, wait.ErrWaitTimeout
|
return gottenObj, false, errWaitTimeoutWithName
|
||||||
default:
|
default:
|
||||||
return gottenObj, false, err
|
return gottenObj, false, err
|
||||||
}
|
}
|
||||||
@ -449,3 +451,7 @@ func (w ConditionalWait) isConditionMet(event watch.Event) (bool, error) {
|
|||||||
obj := event.Object.(*unstructured.Unstructured)
|
obj := event.Object.(*unstructured.Unstructured)
|
||||||
return w.checkCondition(obj)
|
return w.checkCondition(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func extendErrWaitTimeout(err error, info *resource.Info) error {
|
||||||
|
return fmt.Errorf("%s on %s/%s", err.Error(), info.Mapping.Resource.Resource, info.Name)
|
||||||
|
}
|
||||||
|
@ -18,11 +18,9 @@ package wait
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"testing"
|
|
||||||
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"strings"
|
"strings"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
|
|
||||||
@ -32,7 +30,6 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime"
|
"k8s.io/apimachinery/pkg/runtime"
|
||||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||||
"k8s.io/apimachinery/pkg/types"
|
"k8s.io/apimachinery/pkg/types"
|
||||||
"k8s.io/apimachinery/pkg/util/wait"
|
|
||||||
"k8s.io/apimachinery/pkg/watch"
|
"k8s.io/apimachinery/pkg/watch"
|
||||||
"k8s.io/cli-runtime/pkg/genericclioptions"
|
"k8s.io/cli-runtime/pkg/genericclioptions"
|
||||||
"k8s.io/cli-runtime/pkg/genericclioptions/printers"
|
"k8s.io/cli-runtime/pkg/genericclioptions/printers"
|
||||||
@ -203,7 +200,7 @@ func TestWaitForDeletion(t *testing.T) {
|
|||||||
},
|
},
|
||||||
timeout: 1 * time.Second,
|
timeout: 1 * time.Second,
|
||||||
|
|
||||||
expectedErr: wait.ErrWaitTimeout.Error(),
|
expectedErr: "timed out waiting for the condition on theresource/name-foo",
|
||||||
validateActions: func(t *testing.T, actions []clienttesting.Action) {
|
validateActions: func(t *testing.T, actions []clienttesting.Action) {
|
||||||
if len(actions) != 2 {
|
if len(actions) != 2 {
|
||||||
t.Fatal(spew.Sdump(actions))
|
t.Fatal(spew.Sdump(actions))
|
||||||
@ -254,7 +251,7 @@ func TestWaitForDeletion(t *testing.T) {
|
|||||||
},
|
},
|
||||||
timeout: 3 * time.Second,
|
timeout: 3 * time.Second,
|
||||||
|
|
||||||
expectedErr: wait.ErrWaitTimeout.Error(),
|
expectedErr: "timed out waiting for the condition on theresource/name-foo",
|
||||||
validateActions: func(t *testing.T, actions []clienttesting.Action) {
|
validateActions: func(t *testing.T, actions []clienttesting.Action) {
|
||||||
if len(actions) != 4 {
|
if len(actions) != 4 {
|
||||||
t.Fatal(spew.Sdump(actions))
|
t.Fatal(spew.Sdump(actions))
|
||||||
@ -502,7 +499,7 @@ func TestWaitForCondition(t *testing.T) {
|
|||||||
},
|
},
|
||||||
timeout: 1 * time.Second,
|
timeout: 1 * time.Second,
|
||||||
|
|
||||||
expectedErr: wait.ErrWaitTimeout.Error(),
|
expectedErr: "timed out waiting for the condition on theresource/name-foo",
|
||||||
validateActions: func(t *testing.T, actions []clienttesting.Action) {
|
validateActions: func(t *testing.T, actions []clienttesting.Action) {
|
||||||
if len(actions) != 2 {
|
if len(actions) != 2 {
|
||||||
t.Fatal(spew.Sdump(actions))
|
t.Fatal(spew.Sdump(actions))
|
||||||
@ -553,7 +550,7 @@ func TestWaitForCondition(t *testing.T) {
|
|||||||
},
|
},
|
||||||
timeout: 3 * time.Second,
|
timeout: 3 * time.Second,
|
||||||
|
|
||||||
expectedErr: wait.ErrWaitTimeout.Error(),
|
expectedErr: "timed out waiting for the condition on theresource/name-foo",
|
||||||
validateActions: func(t *testing.T, actions []clienttesting.Action) {
|
validateActions: func(t *testing.T, actions []clienttesting.Action) {
|
||||||
if len(actions) != 4 {
|
if len(actions) != 4 {
|
||||||
t.Fatal(spew.Sdump(actions))
|
t.Fatal(spew.Sdump(actions))
|
||||||
|
Loading…
Reference in New Issue
Block a user