kubernetes / kubectl

Issue tracker and mirror of kubectl code
Apache License 2.0
2.75k stars 894 forks source link

kubectl get: when resource name is in form resource_type/name the error occurs #1607

Open GrigoriyMikhalkin opened 1 month ago

GrigoriyMikhalkin commented 1 month ago

What happened?

When command kubectl get pods,deployments deployment.apps/coredns -n kube-system is executed it returns the error:

error: arguments in resource/name form may not have more than one slash

What did you expect to happen?

kubectl get should return deployment.apps/coredns resource.

How can we reproduce it (as minimally and precisely as possible)?

Create local cluster with kind/minikube/etc:

kind create cluster

By default it should have coredns deployment, try to run:

kubectl get pods,deployments deployment.apps/coredns -n kube-system

Anything else we need to know?

It's not necessary should be treated as a bug but maybe as a bad error description. Up to discussion.

Kubernetes version

```console $ kubectl version Client Version: v1.29.5 Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3 Server Version: v1.29.2 ```

Cloud provider

Local setup with Kind

OS version

```console # On Linux: $ cat /etc/os-release # paste output here $ uname -a # paste output here # On Windows: C:\> wmic os get Caption, Version, BuildNumber, OSArchitecture # paste output here ```

Install tools

Container runtime (CRI) and version (if applicable)

Related plugins (CNI, CSI, ...) and versions (if applicable)

k8s-ci-robot commented 1 month ago

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.
alex-kattathra-johnson commented 1 month ago

I think the error is because each resource type is prepended to the resource name, so the resource names end up being [pods/deployment.apps/coredns deployments/deployment.apps/coredns] which has more than 2 parts when split by the /. kubectl get pods,deployments coredns -n kube-system gives the desired outcome.

GrigoriyMikhalkin commented 1 month ago

@alex-kattathra-johnson Yes.

The question is should the behavior be changed or should it return more clear error message to the user in that case.

neolit123 commented 1 month ago

/sig cli

ardaguclu commented 4 weeks ago

/transfer kubectl

ardaguclu commented 1 week ago

What is the error message in here, is this?

get pods,deployments deployment.apps/coredns -n kube-system

GrigoriyMikhalkin commented 1 week ago

@ardaguclu The error is error: arguments in resource/name form may not have more than one slash. Fixed original post. Thanks for noticing!

ardaguclu commented 5 days ago

Command is invalid and the actual command should be kubectl get deployment.apps/coredns -n kube-system.

I see that error message is not very descriptive. However, I don't think, we can (would want to) change it, because there are many other components relying on this functionality and whatever the message we change to, it will not be descriptive for another component. I'd prefer closing this.