diff options
author | Peter Hunt <pehunt@redhat.com> | 2019-07-19 16:19:17 -0400 |
---|---|---|
committer | Peter Hunt <pehunt@redhat.com> | 2019-07-23 13:29:33 -0400 |
commit | 35ba77e0409036c455f85d9f8fcbe361f0693335 (patch) | |
tree | 20ade93fa60858856a861d279bfa3991f702cf7b /pkg/varlinkapi/containers.go | |
parent | 2a474c88c9ffc7221b09513ad4db8720ca7661cb (diff) | |
download | podman-35ba77e0409036c455f85d9f8fcbe361f0693335.tar.gz podman-35ba77e0409036c455f85d9f8fcbe361f0693335.tar.bz2 podman-35ba77e0409036c455f85d9f8fcbe361f0693335.zip |
Update e2e tests for remote exec
including changing -l to the container id
and separating a case of setting the env that remote can't handle
Signed-off-by: Peter Hunt <pehunt@redhat.com>
Diffstat (limited to 'pkg/varlinkapi/containers.go')
-rw-r--r-- | pkg/varlinkapi/containers.go | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/pkg/varlinkapi/containers.go b/pkg/varlinkapi/containers.go index 4714f3fa0..a70a87675 100644 --- a/pkg/varlinkapi/containers.go +++ b/pkg/varlinkapi/containers.go @@ -800,51 +800,46 @@ func (i *LibpodAPI) ExecContainer(call iopodman.VarlinkCall, opts iopodman.ExecO call.ReplyExecContainer() resizeChan := make(chan remotecommand.TerminalSize) - errChan := make(chan error) reader, writer, _, pipeWriter, streams := setupStreams(call) //reader, _, _, pipeWriter, streams := setupStreams(call) - ecChan := make(chan uint32, 1) + type ExitCodeError struct { + ExitCode uint32 + Error error + } + ecErrChan := make(chan ExitCodeError, 1) go func() { - fmt.Printf("ExecContainer Start Reader\n") if err := virtwriter.Reader(reader, nil, nil, pipeWriter, resizeChan, nil); err != nil { - //fmt.Printf("ExecContainer Reader err %s, %s\n", err.Error(), errors.Cause(err).Error()) - errChan <- errors.Wrapf(err, "error") + ecErrChan <- ExitCodeError{ + 125, //TODO FIXME magic number, define package? + err, + } } }() - fmt.Printf("ExecContainer Start ctr.Exec\n") - // TODO detach keys and resize - // TODO add handling for exit code - // TODO capture exit code and return to main thread + // TODO FIXME detach keys go func() { ec, err := ctr.Exec(opts.Tty, opts.Privileged, envs, opts.Cmd, user, workDir, streams, 0, resizeChan, "") if err != nil { logrus.Errorf("ExecContainer Exec err %s, %s\n", err.Error(), errors.Cause(err).Error()) - errChan <-err } - ecChan <-uint32(ec) - + ecErrChan <- ExitCodeError{ + uint32(ec), + err, + } }() - ec := uint32(125) - var execErr error - select { - case execErr = <-errChan: - fmt.Println(execErr.Error()) - case ec = <-ecChan: - fmt.Println("found", ec) - } + ecErr := <-ecErrChan - // TODO FIXME prevent all of vthese conversions - if err = virtwriter.HangUp(writer, int(ec)); err != nil { + // TODO FIXME prevent all of these conversions + if err = virtwriter.HangUp(writer, int(ecErr.ExitCode)); err != nil { logrus.Errorf("ExecContainer failed to HANG-UP on %s: %s", ctr.ID(), err.Error()) } - defer fmt.Println("Succeeded in exec'ing") + if err := call.Writer.Flush(); err != nil { logrus.Errorf("Exec Container err: %s", err.Error()) } - return execErr + return ecErr.Error } |