-
Notifications
You must be signed in to change notification settings - Fork 39k
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
Mark --pod as deprecated for kubectl exec and port-forward #54629
Conversation
Is there a deprecation announcement? |
/ok-to-test |
Hi @yuexiao-wang, thanks for working on this. Did you test this code? What happened? |
@yuexiao-wang I tried to run it, and it didn't do what I expected:
Would you mind looking into these two problems? Also I might remember that @alexandercampbell was testing the deprecation flag somehow, maybe you could look for his code and find how he was doing it. Thank you! |
Thanks for review. I will check it |
@apelisse I am sure that it is a issue of spf13/cobra used by kubernetes. We can find this issue of cobra as follows: I find cobra is updated in kompose: Should we update cobra in kubernetes? According to https://github.com/kubernetes/community/blob/master/contributors/devel/godep.md, I encounter some problems when update cobra in my development enviroment |
/retest |
I don't think that issue is related. You could try to apply that one pull-request in your |
pkg/kubectl/cmd/exec.go
Outdated
@@ -85,6 +85,7 @@ func NewCmdExec(f cmdutil.Factory, cmdIn io.Reader, cmdOut, cmdErr io.Writer) *c | |||
}, | |||
} | |||
cmd.Flags().StringVarP(&options.PodName, "pod", "p", "", "Pod name") | |||
cmd.Flags().MarkDeprecated("pod", "This flag is DEPRECATED and will be removed in a future version. Use exec POD_NAME instead.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add TODO comment, and relate an issue to record this.
Signed-off-by: yuexiao-wang <wang.yuexiao@zte.com.cn>
@apelisse Sorry, I am respond late.
|
@yuexiao-wang what behavior are you expecting from |
@apelisse I expect that kubectl can show deprecated messages in help output. for example I use MarkDeprecated from spf13/cobra to mark the option as deprected, but it doesn't work. I think it need to update spf13/cobra, then my PR can work to show deprecated option |
If I understand you incorrectly, please inform me. |
@yuexiao-wang I think you need another PR to update the |
@mengqiy Thanks for review. I am no familiar to update cobra in vendor. Should I read https://github.com/kubernetes/community/blob/master/contributors/devel/godep.md? |
@yuexiao-wang I agree that this is probably what we want. Have you looked at the code for |
@yuexiao-wang If we can confirm latest |
I confirm that the latest cobra don't support to show deprecated message in the help output, and they have planed to support this feature in v2.0.0. spf13/cobra#466 fixes the issue to show deprecated message when run cli command. |
@apelisse Could you any suggestion about kubernetes/kubectl#104 |
@yuexiao-wang Thank you for investigating that issue. All of this makes sense. What do you think we should be doing? |
When? AFAIK Cobra is now 0.0.1, isn't it? |
Yes, Cobra is now 0.0.1. The member didn't tell me the release time of cobra as follows. |
I'm still waiting for a deeper analysis:
@yuexiao-wang are you willing to do that? Thanks, |
I will do it when update vendor spf13/cobra at #53631
I am no familiar with codes of cobra and no sure to fix the issue in cobra. |
OK Let's wait for that PR to get merged, and see what's needed then |
I've just checked-out the code of #53631, and rebased it on the most recent master. Compiled
|
@yuexiao-wang Any news on that? If not I'll probably close that PR |
Some analysis of this issue. Since commit spf13/pflag@329ebf1 deprecated messages are hidden from help menu by default, but can be shown if the developer changes the flag's hidden property to false ( If https://github.com/spf13/pflag/blob/3ebe029320b2676d667ae88da602a5f854788a8a/flag.go#L719-L721 But this function is not called in our case, because kubectl uses a custom template for flags usage. It replaces the default template https://github.com/spf13/cobra/blob/7c4570c3ebeb8129a1f7456d0908a8b676b6f9f1/command.go#L410-L411 with this one: kubernetes/pkg/kubectl/cmd/templates/templates.go Lines 51 to 54 in d244fa9
and this one utilizes the
which outputs flag usage with the
This can be fixed by changing a few lines in usage := flag.Usage
if len(flag.Deprecated) != 0 {
usage += fmt.Sprintf(" (DEPRECATED: %s)", flag.Deprecated)
}
fmt.Fprintf(x, format, flag.Shorthand, flag.Name, flag.DefValue, usage) Apart from that it seems that rebasing the PR of @yuexiao-wang with master effectively hides the Actually that was one of the suggested solutions with kubernetes/kubectl#104, so the change to @apelisse If everyone agrees that hiding deprecated flags from the menu is just enough, would it be posible to reopen this PR? |
@yuexiao-wang: PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: yuexiao-wang If they are not already assigned, you can assign the PR to them by writing The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Actually @quasoft, do you mind opening a new PR? |
@yuexiao-wang: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Automatic merge from submit-queue (batch tested with PRs 66593, 66727, 66558). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Mark --pod/-p flag of kubectl exec command as deprecated **What this PR does / why we need it**: Marks the `--pod` (`-p` shorthand) flag of kubectl `exec` command as deprecated. Hides the flag from the help menu, but shows a message when command is executed with this flag. **Which issue this PR fixes**: Fixes: kubernetes/kubectl#104 This is a remake of PR #54629. **Release note**: ```release-note Flag --pod (-p shorthand) of kubectl exec command marked as deprecated ```
Signed-off-by: yuexiao-wang wang.yuexiao@zte.com.cn
What this PR does / why we need it:
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged):fixes kubernetes/kubectl#104
Special notes for your reviewer:
@apelisse @php-coder
Release note: