Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
892f15d9
Commit
892f15d9
authored
Jan 25, 2019
by
bpopovschi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added resource name to timeout error output on WAIT cmd
parent
d654b49c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
15 deletions
+17
-15
BUILD
pkg/kubectl/cmd/wait/BUILD
+0
-1
wait.go
pkg/kubectl/cmd/wait/wait.go
+12
-6
wait_test.go
pkg/kubectl/cmd/wait/wait_test.go
+5
-8
No files found.
pkg/kubectl/cmd/wait/BUILD
View file @
892f15d9
...
...
@@ -51,7 +51,6 @@ go_test(
"//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/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/cli-runtime/pkg/genericclioptions:go_default_library",
"//staging/src/k8s.io/cli-runtime/pkg/genericclioptions/printers:go_default_library",
...
...
pkg/kubectl/cmd/wait/wait.go
View file @
892f15d9
...
...
@@ -292,9 +292,10 @@ func IsDeleted(info *resource.Info, o *WaitOptions) (runtime.Object, bool, error
}
timeout
:=
endTime
.
Sub
(
time
.
Now
())
errWaitTimeoutWithName
:=
extendErrWaitTimeout
(
wait
.
ErrWaitTimeout
,
info
)
if
timeout
<
0
{
// we're out of time
return
gottenObj
,
false
,
wait
.
ErrWaitTimeout
return
gottenObj
,
false
,
errWaitTimeoutWithName
}
ctx
,
cancel
:=
watchtools
.
ContextWithOptionalTimeout
(
context
.
Background
(),
o
.
Timeout
)
...
...
@@ -307,9 +308,9 @@ func IsDeleted(info *resource.Info, o *WaitOptions) (runtime.Object, bool, error
continue
case
err
==
wait
.
ErrWaitTimeout
:
if
watchEvent
!=
nil
{
return
watchEvent
.
Object
,
false
,
wait
.
ErrWaitTimeout
return
watchEvent
.
Object
,
false
,
errWaitTimeoutWithName
}
return
gottenObj
,
false
,
wait
.
ErrWaitTimeout
return
gottenObj
,
false
,
errWaitTimeoutWithName
default
:
return
gottenObj
,
false
,
err
}
...
...
@@ -386,9 +387,10 @@ func (w ConditionalWait) IsConditionMet(info *resource.Info, o *WaitOptions) (ru
}
timeout
:=
endTime
.
Sub
(
time
.
Now
())
errWaitTimeoutWithName
:=
extendErrWaitTimeout
(
wait
.
ErrWaitTimeout
,
info
)
if
timeout
<
0
{
// we're out of time
return
gottenObj
,
false
,
wait
.
ErrWaitTimeout
return
gottenObj
,
false
,
errWaitTimeoutWithName
}
ctx
,
cancel
:=
watchtools
.
ContextWithOptionalTimeout
(
context
.
Background
(),
o
.
Timeout
)
...
...
@@ -401,9 +403,9 @@ func (w ConditionalWait) IsConditionMet(info *resource.Info, o *WaitOptions) (ru
continue
case
err
==
wait
.
ErrWaitTimeout
:
if
watchEvent
!=
nil
{
return
watchEvent
.
Object
,
false
,
wait
.
ErrWaitTimeout
return
watchEvent
.
Object
,
false
,
errWaitTimeoutWithName
}
return
gottenObj
,
false
,
wait
.
ErrWaitTimeout
return
gottenObj
,
false
,
errWaitTimeoutWithName
default
:
return
gottenObj
,
false
,
err
}
...
...
@@ -449,3 +451,7 @@ func (w ConditionalWait) isConditionMet(event watch.Event) (bool, error) {
obj
:=
event
.
Object
.
(
*
unstructured
.
Unstructured
)
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
)
}
pkg/kubectl/cmd/wait/wait_test.go
View file @
892f15d9
...
...
@@ -18,12 +18,10 @@ package wait
import
(
"io/ioutil"
"strings"
"testing"
"time"
"strings"
"github.com/davecgh/go-spew/spew"
"k8s.io/apimachinery/pkg/api/meta"
...
...
@@ -32,7 +30,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/cli-runtime/pkg/genericclioptions/printers"
...
...
@@ -203,7 +200,7 @@ func TestWaitForDeletion(t *testing.T) {
},
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
)
{
if
len
(
actions
)
!=
2
{
t
.
Fatal
(
spew
.
Sdump
(
actions
))
...
...
@@ -254,7 +251,7 @@ func TestWaitForDeletion(t *testing.T) {
},
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
)
{
if
len
(
actions
)
!=
4
{
t
.
Fatal
(
spew
.
Sdump
(
actions
))
...
...
@@ -502,7 +499,7 @@ func TestWaitForCondition(t *testing.T) {
},
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
)
{
if
len
(
actions
)
!=
2
{
t
.
Fatal
(
spew
.
Sdump
(
actions
))
...
...
@@ -553,7 +550,7 @@ func TestWaitForCondition(t *testing.T) {
},
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
)
{
if
len
(
actions
)
!=
4
{
t
.
Fatal
(
spew
.
Sdump
(
actions
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment