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
aea8deee
Unverified
Commit
aea8deee
authored
Feb 07, 2018
by
juanvallejo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix --watch on multiple requests
parent
15dbd4e2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
2 deletions
+31
-2
test-cmd-util.sh
hack/make-rules/test-cmd-util.sh
+12
-0
get.go
pkg/kubectl/cmd/resource/get.go
+19
-2
No files found.
hack/make-rules/test-cmd-util.sh
View file @
aea8deee
...
...
@@ -1430,6 +1430,18 @@ run_kubectl_get_tests() {
# Post-condition: Check if we get a limit and continue
kube::test::if_has_string
"
${
output_message
}
"
"/clusterroles?limit=500 200 OK"
### Test kubectl get chunk size does not result in a --watch error when resource list is served in multiple chunks
# Pre-condition: no ConfigMaps exist
kube::test::get_object_assert configmap
"{{range.items}}{{
$id_field
}}:{{end}}"
''
# Post-condition: Create three configmaps and ensure that we can --watch them with a --chunk-size of 1
kubectl create cm one
"
${
kube_flags
[@]
}
"
kubectl create cm two
"
${
kube_flags
[@]
}
"
kubectl create cm three
"
${
kube_flags
[@]
}
"
output_message
=
$(
kubectl get configmap
--chunk-size
=
1
--watch
--request-timeout
=
1s 2>&1
"
${
kube_flags
[@]
}
"
)
kube::test::if_has_not_string
"
${
output_message
}
"
"watch is only supported on individual resources"
output_message
=
$(
kubectl get configmap
--chunk-size
=
1
--watch-only
--request-timeout
=
1s 2>&1
"
${
kube_flags
[@]
}
"
)
kube::test::if_has_not_string
"
${
output_message
}
"
"watch is only supported on individual resources"
### Test --allow-missing-template-keys
# Pre-condition: no POD exists
create_and_use_new_namespace
...
...
pkg/kubectl/cmd/resource/get.go
View file @
aea8deee
...
...
@@ -463,8 +463,25 @@ func (options *GetOptions) watch(f cmdutil.Factory, cmd *cobra.Command, args []s
if
err
!=
nil
{
return
err
}
if
len
(
infos
)
!=
1
{
return
i18n
.
Errorf
(
"watch is only supported on individual resources and resource collections - %d resources were found"
,
len
(
infos
))
if
len
(
infos
)
>
1
{
gvk
:=
infos
[
0
]
.
Mapping
.
GroupVersionKind
uniqueGVKs
:=
1
// If requesting a resource count greater than a request's --chunk-size,
// we will end up making multiple requests to the server, with each
// request producing its own "Info" object. Although overall we are
// dealing with a single resource type, we will end up with multiple
// infos returned by the builder. To handle this case, only fail if we
// have at least one info with a different GVK than the others.
for
_
,
info
:=
range
infos
{
if
info
.
Mapping
.
GroupVersionKind
!=
gvk
{
uniqueGVKs
++
}
}
if
uniqueGVKs
>
1
{
return
i18n
.
Errorf
(
"watch is only supported on individual resources and resource collections - %d resources were found"
,
uniqueGVKs
)
}
}
filterOpts
:=
cmdutil
.
ExtractCmdPrintOptions
(
cmd
,
options
.
AllNamespaces
)
...
...
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