- Notifications
You must be signed in to change notification settings - Fork928
fix: Improve shutdown procedure of ssh, portforward, wgtunnel cmds#3354
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
We could turn it into a practice to wrap `cmd.Context()` so that we havemore fine-grained control of cancellation. Sometimes in tests we may berunning commands with a context that is never canceled.Related to#3221
@@ -224,13 +236,17 @@ func ssh() *cobra.Command { | |||
sshSession.Stdin = cmd.InOrStdin() | |||
sshSession.Stdout = cmd.OutOrStdout() | |||
sshSession.Stderr = cmd.OutOrStdout() | |||
sshSession.Stderr = cmd.ErrOrStderr() |
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.
This is a drive-by change I did. It seemed wrong but perhaps I didn't understand the purpose?
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.
Seems reasonable to me!
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.
I'm in-between on whether this is desired or not, but I suppose it is. It seems weird to not use the command context directly, but then the caller (like our tests) is responsible for canceling it, which is even weirder I suppose.
We're still inheriting it, so in that sense we're still using it. I think this change can make more sense if we consider other scenarios, like adding tracing to the commands. We'd want to ensure that the context we're passing along contains the tracing information which means we shouldn't be accessing the command context directly. |
We could turn it into a practice to wrap
cmd.Context()
so that we havemore fine-grained control of cancellation. Sometimes in tests we may be
running commands with a context that is never canceled.
Related to#3221