diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-04-30 19:48:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-30 19:48:27 +0200 |
commit | 75189d5b97d18d6b1a229e75d8427c85d2872d61 (patch) | |
tree | e948108e25f374c3e5c11a6ffae45472a578123f /pkg/varlinkapi | |
parent | 488117cb99705f6766ee82b78063951f87099b5b (diff) | |
parent | 4f2666bec072fd0d556ad5b280679386e4f24ed7 (diff) | |
download | podman-75189d5b97d18d6b1a229e75d8427c85d2872d61.tar.gz podman-75189d5b97d18d6b1a229e75d8427c85d2872d61.tar.bz2 podman-75189d5b97d18d6b1a229e75d8427c85d2872d61.zip |
Merge pull request #3026 from baude/remotestartattach
Fix remote-client testing reports
Diffstat (limited to 'pkg/varlinkapi')
-rw-r--r-- | pkg/varlinkapi/attach.go | 14 |
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 { |