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
[WIP] add stream-timeout option to kubectl exec
#38642
[WIP] add stream-timeout option to kubectl exec
#38642
Conversation
Hi @juanvallejo. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with If you have questions or suggestions related to this bot's behavior, please file an issue against the kubernetes/test-infra repository. |
@@ -159,6 +167,8 @@ func (p *ExecOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, argsIn []s | |||
} | |||
} | |||
|
|||
p.StreamTimeout = cmdutil.GetFlagDuration(cmd, "stream-timeout") |
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.
@smarterclayton or @fabianofranz would it make more sense from a user's perspective to just re-use the value from the global --request-timeout
flag, or is it worth adding a third timeout option?
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.
The global --request-timeout
makes sense to me.
Related bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1314240 |
I'm not sure I would call this |
@smarterclayton per this implementation at least, it is a duration timeout. Regardless of user input, it will exit after the specified time |
kubectl exec
kubectl exec
7f7e699
to
544f036
Compare
This patch implements a timeout option for remote streams. This allows a maximum time to be specified for a remote shell to remain open. If a `--stream-timeout` value `> 0` is provided, the stream executor will not wait for the `stdout` and `stderr` streams of a remote shell to finish copying, but will rather close the stream and exit with error `Timeout exceeded for this operation`. Although `kubectl exec` already supports the global `request-timeout` option as well as the local `--timeout` option, the former is only for making ther inital request with a `restclient`, and the latter is the amount of time to wait before a pod is retrieved. Therefore, it was necessary to introduce a third timeout option for specifically timing out the command once inside of a remote shell.
544f036
to
8b59357
Compare
Instead of closing the remote shell after the amount of time defined in --stream-timeout, this patch takes into account any bytes being copied to remoteStdout. If there are any bytes being copied from the remote shell's standard output, the timeout counter will be reset back to the original value provided by the user. The shell will only actually timeout once the timeout counter reaches zero from the original value specified by the user.
@smarterclayton @fabianofranz Inactivity is defined as no bytes being copied from the
The above example will keep running indefinitely, as there is going to be output being copied from
Since the remote shell was inactive for
Because there was data to be copied ( Example with kubectl exec
The example above will also keep running indefinitely, as there will always be data to copy from Hopefully having a timeout on idle, rather than an overall duration timeout will provide a better user experience. I can re-use the value from |
Why would I want a duration timeout on exec?
|
We already support idle timeouts for streaming operations (exec, attach, port forwarding), but the value is only configurable by the cluster administrator. If we decide we want the user to have some amount of control, I would prefer that we pass the user-supplied value through to the kubelet and then use min(user supplied value, admin supplied value). I don't think we need to add any code to implement idle timeout client-side. |
I convert it to an idle timeout here: 40f6ad4 (#38642 (comment))
Sounds good, I could turn this PR into something that updates this. Would the value that is configurable by the cluster admin be handled in |
The cluster admin configuration option is called StreamingConnectionIdleTimeout |
Thanks, I'll put something together |
Based on the original bugzilla for the issue addressed by this PR, the user requested a longer idle timeout, which means that this will still not be solved if we always choose the min value between |
I believe the report in the bz says that the rsh session died after 1 to 2 minutes. The default StreamingConnectionIdleTimeout value is 4 hours. It sounds like something else is going on with that user's environment. I do NOT want to reimplement idle timeouts. I would be open to a discussion about whether or not the user should be allowed to override the cluster admin's setting, although my vote is "no". |
@ncdc @smarterclayton |
Release note:
This patch implements a timeout option for remote streams. This allows a
maximum time to be specified for a remote shell to remain open. If a
--stream-timeout
value> 0
is provided, the stream executor will notwait for the
stdout
andstderr
streams of a remote shell to finishcopying, but will rather close the stream and exit with error
Timeout exceeded for this operation
.Although
kubectl exec
already supports the globalrequest-timeout
option as well as the local--timeout
option, theformer is only for making ther inital request with a
restclient
, andthe latter is the amount of time to wait before a pod is retrieved.
Therefore, it was necessary to introduce a third timeout option for
specifically timing out the command once inside of a remote shell.
Example
@kubernetes/cli-review @fabianofranz