From 479eeac62cd74e32cbe74fc8afbfc82d4d8a8abd Mon Sep 17 00:00:00 2001 From: Peter Hunt Date: Mon, 22 Jul 2019 15:12:29 -0400 Subject: move editing of exitCode to runtime There's no way to get the error if we successfully get an exit code (as it's just printed to stderr instead). instead of relying on the error to be passed to podman, and edit based on the error code, process it on the varlink side instead Also move error codes to define package Signed-off-by: Peter Hunt --- pkg/varlinkapi/containers.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'pkg/varlinkapi') diff --git a/pkg/varlinkapi/containers.go b/pkg/varlinkapi/containers.go index a70a87675..fa17bed84 100644 --- a/pkg/varlinkapi/containers.go +++ b/pkg/varlinkapi/containers.go @@ -812,7 +812,7 @@ func (i *LibpodAPI) ExecContainer(call iopodman.VarlinkCall, opts iopodman.ExecO go func() { if err := virtwriter.Reader(reader, nil, nil, pipeWriter, resizeChan, nil); err != nil { ecErrChan <- ExitCodeError{ - 125, //TODO FIXME magic number, define package? + define.ExecErrorCodeGeneric, err, } } @@ -833,7 +833,15 @@ func (i *LibpodAPI) ExecContainer(call iopodman.VarlinkCall, opts iopodman.ExecO ecErr := <-ecErrChan // TODO FIXME prevent all of these conversions - if err = virtwriter.HangUp(writer, int(ecErr.ExitCode)); err != nil { + exitCode := int(ecErr.ExitCode) + if errors.Cause(ecErr.Error) == define.ErrOCIRuntimePermissionDenied { + exitCode = define.ExecErrorCodeCannotInvoke + } + if errors.Cause(ecErr.Error) == define.ErrOCIRuntimeNotFound { + exitCode = define.ExecErrorCodeNotFound + } + + if err = virtwriter.HangUp(writer, exitCode); err != nil { logrus.Errorf("ExecContainer failed to HANG-UP on %s: %s", ctr.ID(), err.Error()) } -- cgit v1.2.3-54-g00ecf