diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-02-13 22:55:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-13 22:55:52 +0100 |
commit | dfc64e15d7f8b1715798fd68bd3ff74ae192b354 (patch) | |
tree | 28fff3097e5705623bc48670c67dee64a5296329 /cmd/podman/run.go | |
parent | 29d9ccf38158235ef37e4f5c20ad152bb396e3b9 (diff) | |
parent | 9d4e7fe58b10c4130340a151a377cf7be8aaa810 (diff) | |
download | podman-dfc64e15d7f8b1715798fd68bd3ff74ae192b354.tar.gz podman-dfc64e15d7f8b1715798fd68bd3ff74ae192b354.tar.bz2 podman-dfc64e15d7f8b1715798fd68bd3ff74ae192b354.zip |
Merge pull request #2319 from mheon/unconditional_cleanup
Fix manual detach from containers to not wait for exit
Diffstat (limited to 'cmd/podman/run.go')
-rw-r--r-- | cmd/podman/run.go | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/cmd/podman/run.go b/cmd/podman/run.go index 8649dc190..16ec7c3c0 100644 --- a/cmd/podman/run.go +++ b/cmd/podman/run.go @@ -118,6 +118,14 @@ func runCmd(c *cliconfig.RunValues) error { } } if err := startAttachCtr(ctr, outputStream, errorStream, inputStream, c.String("detach-keys"), c.Bool("sig-proxy"), true); err != nil { + // We've manually detached from the container + // Do not perform cleanup, or wait for container exit code + // Just exit immediately + if errors.Cause(err) == libpod.ErrDetach { + exitCode = 0 + return nil + } + // This means the command did not exist exitCode = 127 if strings.Index(err.Error(), "permission denied") > -1 { @@ -147,28 +155,12 @@ func runCmd(c *cliconfig.RunValues) error { exitCode = int(ecode) } - if createConfig.Rm { - return runtime.RemoveContainer(ctx, ctr, true) - } - - if err := ctr.Cleanup(ctx); err != nil { - // If the container has been removed already, no need to error on cleanup - // Also, if it was restarted, don't error either - if errors.Cause(err) == libpod.ErrNoSuchCtr || - errors.Cause(err) == libpod.ErrCtrRemoved || - errors.Cause(err) == libpod.ErrCtrStateInvalid { - return nil - } - - return err - } - return nil } // Read a container's exit file func readExitFile(runtimeTmp, ctrID string) (int, error) { - exitFile := filepath.Join(runtimeTmp, "exits", ctrID) + exitFile := filepath.Join(runtimeTmp, "exits", fmt.Sprintf("%s-old", ctrID)) logrus.Debugf("Attempting to read container %s exit code from file %s", ctrID, exitFile) |