summaryrefslogtreecommitdiff
path: root/pkg/varlinkapi/attach.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-04-25 16:18:40 -0500
committerbaude <bbaude@redhat.com>2019-04-26 10:39:29 -0500
commit4f2666bec072fd0d556ad5b280679386e4f24ed7 (patch)
tree366e59bde914cbc50c951b4bf96835629f30da6d /pkg/varlinkapi/attach.go
parenta01c62fcbde1afdc77aa05b71c3c84ddacf7fc55 (diff)
downloadpodman-4f2666bec072fd0d556ad5b280679386e4f24ed7.tar.gz
podman-4f2666bec072fd0d556ad5b280679386e4f24ed7.tar.bz2
podman-4f2666bec072fd0d556ad5b280679386e4f24ed7.zip
Fix remote-client testing reports
Ensure when using remote attach --no-stdin a mock device is used to prevent stdin and not nil. This fixes issue #3009. When starting a container with the remote client, if the container is already running and the user asks to attach, we should just attach. This fixes issue #3011 Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/varlinkapi/attach.go')
-rw-r--r--pkg/varlinkapi/attach.go14
1 files changed, 10 insertions, 4 deletions
diff --git a/pkg/varlinkapi/attach.go b/pkg/varlinkapi/attach.go
index 9e2a265be..6c62d3514 100644
--- a/pkg/varlinkapi/attach.go
+++ b/pkg/varlinkapi/attach.go
@@ -53,7 +53,13 @@ func (i *LibpodAPI) Attach(call iopodman.VarlinkCall, name string, detachKeys st
if err != nil {
return call.ReplyErrorOccurred(err.Error())
}
-
+ state, err := ctr.State()
+ if err != nil {
+ return call.ReplyErrorOccurred(err.Error())
+ }
+ if !start && state != libpod.ContainerStateRunning {
+ return call.ReplyErrorOccurred("container must be running to attach")
+ }
reader, writer, _, pw, streams := setupStreams(call)
go func() {
@@ -62,10 +68,10 @@ func (i *LibpodAPI) Attach(call iopodman.VarlinkCall, name string, detachKeys st
}
}()
- if start {
- finalErr = startAndAttach(ctr, streams, detachKeys, resize, errChan)
- } else {
+ if state == libpod.ContainerStateRunning {
finalErr = attach(ctr, streams, detachKeys, resize, errChan)
+ } else {
+ finalErr = startAndAttach(ctr, streams, detachKeys, resize, errChan)
}
if finalErr != libpod.ErrDetach && finalErr != nil {