-
Notifications
You must be signed in to change notification settings - Fork 40k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kubectl get
displays an empty list + returns an error when trying to get a nonexistent resource
#28243
Comments
cc @deads2k |
We don't, asking for a singular resource is an error and should not print On Jun 29, 2016, at 2:39 PM, Andy Goldstein notifications@github.com $ kubectl get pod/foo -o yaml Prior to #23673 #23673 and @kubernetes/kubectl https://github.com/orgs/kubernetes/teams/kubectl — |
I have a local change that does this:
It still seems a little strange, if you ask me... Also, if you mix getting a pod that does exist with one that does not:
Is this acceptable? |
IMO it's more natural to have no list for Also the error message "pods not found" is strange. |
Yeah, I think if you ask for a list of things and they're all 404, it probably makes sense to return no list. What about in my 2nd example, where you ask for 2 pods and it can only find 1? Agreed about the error message, but let's leave that oddity for another issue if that's ok? 😄 |
I think its a little weird that asking for one resource by name and getting no results is different than asking for two resources by name and getting no results. |
For the text output the behavior is certainly fine to print out 1 pod + 1 error. |
An alternative to get it consistent: print an empty yaml list also for |
That's what master currently does |
Oh right, that's what this issue is all about :) |
You could also go the other way and have no list output if you requested single resources that all 404. Truth be told the empty list plus error plus non-zero return code doesn't bother me. |
I think printing empty list when one resource was requested is a bad thing. It basically returns different data type than requested by user. In the one case it is a single resource and in the other case it is a list. A script can certainly handle that but it looks ugly and inconsistent to me. IMO if specific resource is explicitly requested by user and is not found (regardless if user requested 2, 3 or more resources), then command should return an error exit code and a string of some sort containing "not found" (as before). Now if you list by label, it is perfectly fine to return success with empty list. That's like
-- my two cents |
+1 |
"singular" is the signal that the user asked for a single item, so we should return an error (instead of displaying empty lists).
|
@smarterclayton , besides singular, we need to also account for "specific". I liked most the idea to be like |
…luar Automatic merge from submit-queue kubectl: don't display an empty list when trying to get a single resource that isn't found Return immediately when attempting to get a singular resource that isn't found, so that we avoid printing out a List if the output format is something like json or yaml. Before: ``` $ kubectl get pod/foo -o yaml apiVersion: v1 items: [] kind: List metadata: {} pods "foo" not found ``` After: ``` $ kubectl get pod/foo -o yaml pods "foo" not found ``` Fixes #28243 @kubernetes/kubectl @kubernetes/rh-ux @smarterclayton @liggitt @deads2k @metral
Prior to #23673 and #26686, we did not display the empty list; we only displayed the error. I'm guessing we don't want to display the empty list, do we?
@kubernetes/kubectl @kubernetes/rh-ux @kubernetes/rh-cluster-infra @smarterclayton @liggitt
The text was updated successfully, but these errors were encountered: