简体   繁体   English

当Kubernetes client-go Remotecommand Stream完成时?

[英]When Kubernetes client-go Remotecommand Stream finishes?

I am using this Remotecommand here https://github.com/kubernetes/client-go/blob/master/tools/remotecommand/remotecommand.go#L108 to execute a command on a pod and stream the result to an io.Writer . 我在这里https://github.com/kubernetes/client-go/blob/master/tools/remotecommand/remotecommand.go#L108使用此Remotecommand在pod上执行命令并将结果流式传输到io.Writer As stated in the command above the function in the link the Stream does finish only when client or server disconnect. 如上面命令中所述,仅当客户端或服务器断开连接时,流中的功能才完成。 As the Stream config has only one command attached, why doesn't it close when the command has exited? 由于Stream配置仅附加了一个命令,为什么在退出命令后不将其关闭? How can I know when the command has finished? 我怎么知道命令何时完成?

Particularly I am transferring the result of tar -cf - ... to the client and want to know when its finished. 特别是我正在将tar -cf - ...的结果传输给客户端,并想知道它何时完成。

I noticed that the Stream Function does run synchronously and blocks until the remote command has finished. 我注意到流功能确实同步运行并阻塞,直到远程命令完成为止。 Adding a one second timeout after calling writer.Close() prevented that the program exited before I could handle the received tar archive. 在调用writer.Close()之后添加一秒钟的超时,可以防止程序在我可以处理收到的tar存档之前退出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM