kubectl logs command with label selector option doesn't print error messages when there are no pod type resources matching labels

Created on 28 Jan 2020  路  10Comments  路  Source: kubernetes/kubectl

Is this a request for help? (If yes, you should use our troubleshooting guide and community support channels, see http://kubernetes.io/docs/troubleshooting/.):

What keywords did you search in Kubernetes issues before filing this one? (If you have found any duplicates, you should instead reply there.):

is:issue "kubectl logs"

Is this a BUG REPORT or FEATURE REQUEST? (choose one): BUG REPORT

Kubernetes version (use kubectl version):

Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.0", GitCommit:"70132b0f130acc0bed193d9ba59dd186f0e634cf", GitTreeState:"clean", BuildDate:"2019-12-13T11:51:44Z", GoVersion:"go1.13.4", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.5", GitCommit:"20c265fef0741dd71a66480e35bd69f18351daea", GitTreeState:"clean", BuildDate:"2019-10-15T19:07:57Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"linux/amd64"}

What happened:

There are no pod type resources in default namespace.

$ kubectl get pods -l test=test
No resources found in default namespace.

$ kubectl logs -l test=test

$ kubectl logs test
Error from server (NotFound): pods "test" not found

$ kubectl logs deployments/test
Error from server (NotFound): deployments.extensions "test" not found

What you expected to happen:

kubectl logs (POD | TYPE/NAME) command and kubectl get TYPE command with label selector option print error messages when there are no pod type resources matching pod name or type/name.
However, kubectl logs command with label selector option doesn't print error messages when there are no pod type resources matching labels.
I think it should print the error message "No resources found"

How to reproduce it (as minimally and precisely as possible):

See the examples above.

kinbug prioritbacklog

All 10 comments

/assign

@cprayer just want to confirm that you are working on this one

@eddiezane
I'm new to Go language / kubectl source code and have been busy this month. So It's delayed. But this issue is on progress. Thank you for asking about it.

The kubectl logs does not work when you give the correct label also, it works with get only. And this makes sense to me as they can be multiple pods with the matching label

Why do you bother about showing error message in the negative case, you are not supposed to be using the label filter with the logs command at all

@bseenu
label selector is supported option in logs command. it works well.
In case, if it doesn't care about error message, you don't distinguish between no pod and no log of pod.
I think it's helpful to know about existence of pod matching label.

@cprayer Sorry my bad, i was not passing the container when i checked it, just came across this as well - https://github.com/kubernetes/kubernetes/issues/54000

/kind bug

/priority backlog

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

/remove-lifecycle stale

Was this page helpful?
0 / 5 - 0 ratings