Support detaching in CRI attach
Signed-off-by: Mrunal Patel <mpatel@redhat.com>
This commit is contained in:
parent
6e53568d15
commit
d0486e542f
1 changed files with 9 additions and 4 deletions
|
@ -11,6 +11,7 @@ import (
|
|||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/kubernetes-incubator/cri-o/oci"
|
||||
"github.com/kubernetes-incubator/cri-o/utils"
|
||||
"golang.org/x/net/context"
|
||||
pb "k8s.io/kubernetes/pkg/kubelet/api/v1alpha1/runtime"
|
||||
kubecontainer "k8s.io/kubernetes/pkg/kubelet/container"
|
||||
|
@ -74,18 +75,22 @@ func (ss streamService) Attach(containerID string, inputStream io.Reader, output
|
|||
}()
|
||||
}
|
||||
|
||||
stdinDone := make(chan struct{})
|
||||
stdinDone := make(chan error)
|
||||
go func() {
|
||||
var err error
|
||||
if inputStream != nil {
|
||||
io.Copy(conn, inputStream)
|
||||
_, err = utils.CopyDetachable(conn, inputStream, nil)
|
||||
}
|
||||
close(stdinDone)
|
||||
stdinDone <- err
|
||||
}()
|
||||
|
||||
select {
|
||||
case err := <-receiveStdout:
|
||||
return err
|
||||
case <-stdinDone:
|
||||
case err := <-stdinDone:
|
||||
if _, ok := err.(utils.DetachError); ok {
|
||||
return nil
|
||||
}
|
||||
if outputStream != nil || errorStream != nil {
|
||||
return <-receiveStdout
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue