kubernetes / kubectl

Issue tracker and mirror of kubectl code
Apache License 2.0
2.86k stars 921 forks source link

`kubectl label`: Inconsistent messaging when both adding and removing labels #1323

Open KnVerey opened 1 year ago

KnVerey commented 1 year ago

What happened:

What you expected to happen: kubectl label should produce a consistent, accurate message when labels are both removed and added at the same time (maybe just "labels modified" for simplicity?).

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

$ kubectl label pod mypod a=b aa=bb
pod/mypod labeled

$ kubectl label pod mypod a- ee=ff
pod/mypod labeled # because the new label is textually longer

$ kubectl label pod mypod aa- e=f # same operations as above
pod/mypod unlabeled # different message, because the old label is textually longer

Anything else we need to know?: The problem seems to be the use of a length comparison in this function: https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/kubectl/pkg/cmd/label/label.go#L399-L408. That might be reliable if labels could only be added OR removed by an operation, but as in the examples above, both are possible at once.

Environment:

/sig cli

Fixed by https://github.com/kubernetes/kubernetes/pull/110124

ardaguclu commented 1 year ago

Although there is no direct relation but to distinguish label/unlabel message also causing this issue https://github.com/kubernetes/kubectl/issues/1265 as a symptom. If we decide to just say modified, this issue will also be fixed.

astraw99 commented 1 year ago

Got it, will fix it in PR https://github.com/kubernetes/kubernetes/pull/110124

eddiezane commented 1 year ago

/triage accepted /priority backlog /assign @astraw99

k8s-triage-robot commented 1 year ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

astraw99 commented 1 year ago

/remove-lifecycle stale

k8s-triage-robot commented 8 months ago

This issue has not been updated in over 1 year, and should be re-triaged.

You can:

For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/

/remove-triage accepted

TessaIO commented 6 months ago

/assign

k8s-triage-robot commented 3 months ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

astraw99 commented 3 months ago

/remove-lifecycle stale

k8s-triage-robot commented 12 hours ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale