mirror of https://github.com/k3s-io/k3s
Merge pull request #69196 from CaoShuFeng/job.yaml
fix kubectl wait with no resource name providedpull/58/head
commit
7cf211d7de
|
@ -249,6 +249,9 @@ func (o *WaitOptions) RunWait() error {
|
||||||
func IsDeleted(info *resource.Info, o *WaitOptions) (runtime.Object, bool, error) {
|
func IsDeleted(info *resource.Info, o *WaitOptions) (runtime.Object, bool, error) {
|
||||||
endTime := time.Now().Add(o.Timeout)
|
endTime := time.Now().Add(o.Timeout)
|
||||||
for {
|
for {
|
||||||
|
if len(info.Name) == 0 {
|
||||||
|
return info.Object, false, fmt.Errorf("resource name must be provided")
|
||||||
|
}
|
||||||
gottenObj, err := o.DynamicClient.Resource(info.Mapping.Resource).Namespace(info.Namespace).Get(info.Name, metav1.GetOptions{})
|
gottenObj, err := o.DynamicClient.Resource(info.Mapping.Resource).Namespace(info.Namespace).Get(info.Name, metav1.GetOptions{})
|
||||||
if apierrors.IsNotFound(err) {
|
if apierrors.IsNotFound(err) {
|
||||||
return info.Object, true, nil
|
return info.Object, true, nil
|
||||||
|
@ -334,6 +337,9 @@ type ConditionalWait struct {
|
||||||
func (w ConditionalWait) IsConditionMet(info *resource.Info, o *WaitOptions) (runtime.Object, bool, error) {
|
func (w ConditionalWait) IsConditionMet(info *resource.Info, o *WaitOptions) (runtime.Object, bool, error) {
|
||||||
endTime := time.Now().Add(o.Timeout)
|
endTime := time.Now().Add(o.Timeout)
|
||||||
for {
|
for {
|
||||||
|
if len(info.Name) == 0 {
|
||||||
|
return info.Object, false, fmt.Errorf("resource name must be provided")
|
||||||
|
}
|
||||||
resourceVersion := ""
|
resourceVersion := ""
|
||||||
gottenObj, err := o.DynamicClient.Resource(info.Mapping.Resource).Namespace(info.Namespace).Get(info.Name, metav1.GetOptions{})
|
gottenObj, err := o.DynamicClient.Resource(info.Mapping.Resource).Namespace(info.Namespace).Get(info.Name, metav1.GetOptions{})
|
||||||
switch {
|
switch {
|
||||||
|
|
|
@ -445,6 +445,28 @@ func TestWaitForCondition(t *testing.T) {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "handles empty object name",
|
||||||
|
infos: []*resource.Info{
|
||||||
|
{
|
||||||
|
Mapping: &meta.RESTMapping{
|
||||||
|
Resource: schema.GroupVersionResource{Group: "group", Version: "version", Resource: "theresource"},
|
||||||
|
},
|
||||||
|
Namespace: "ns-foo",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
fakeClient: func() *dynamicfakeclient.FakeDynamicClient {
|
||||||
|
return dynamicfakeclient.NewSimpleDynamicClient(scheme)
|
||||||
|
},
|
||||||
|
timeout: 10 * time.Second,
|
||||||
|
expectedErr: "resource name must be provided",
|
||||||
|
|
||||||
|
validateActions: func(t *testing.T, actions []clienttesting.Action) {
|
||||||
|
if len(actions) != 0 {
|
||||||
|
t.Fatal(spew.Sdump(actions))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "times out",
|
name: "times out",
|
||||||
infos: []*resource.Info{
|
infos: []*resource.Info{
|
||||||
|
|
Loading…
Reference in New Issue