aboutsummaryrefslogtreecommitdiff
path: root/pkg/domain/infra
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2020-05-20 15:29:24 -0400
committerMatthew Heon <matthew.heon@pm.me>2020-05-20 16:11:05 -0400
commit6b9e9610d8ef380d32a682d058157db0f08dd873 (patch)
treeffd1f83437eb6d7e111c91b2036dfd34ff6c78d3 /pkg/domain/infra
parent5ec56dc79093e52abd8e72913aa62932bf12ba6a (diff)
downloadpodman-6b9e9610d8ef380d32a682d058157db0f08dd873.tar.gz
podman-6b9e9610d8ef380d32a682d058157db0f08dd873.tar.bz2
podman-6b9e9610d8ef380d32a682d058157db0f08dd873.zip
Enable cleanup processes for detached exec
The cleanup command creation logic is made public as part of this and wired such that we can call it both within SpecGen (to make container exit commands) and from the ABI detached exec handler. Exit commands are presently only used for detached exec, but theoretically could be turned on for all exec sessions if we wanted (I'm declining to do this because of potential overhead). I also forgot to copy the exit command from the exec config into the ExecOptions struct used by the OCI runtime, so it was not being added. There are also two significant bugfixes for exec in here. One is for updating the status of running exec sessions - this was always failing as I had coded it to remove the exit file *before* reading it, instead of after (oops). The second was that removing a running exec session would always fail because I inverted the check to see if it was running. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'pkg/domain/infra')
-rw-r--r--pkg/domain/infra/abi/containers.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go
index e8eb91644..b4e38ca23 100644
--- a/pkg/domain/infra/abi/containers.go
+++ b/pkg/domain/infra/abi/containers.go
@@ -607,6 +607,20 @@ func (ic *ContainerEngine) ContainerExecDetached(ctx context.Context, nameOrId s
execConfig := makeExecConfig(options)
+ // Make an exit command
+ storageConfig := ic.Libpod.StorageConfig()
+ runtimeConfig, err := ic.Libpod.GetConfig()
+ if err != nil {
+ return "", errors.Wrapf(err, "error retrieving Libpod configuration to build exec exit command")
+ }
+ podmanPath, err := os.Executable()
+ if err != nil {
+ return "", errors.Wrapf(err, "error retrieving executable to build exec exit command")
+ }
+ // TODO: Add some ability to toggle syslog
+ exitCommandArgs := generate.CreateExitCommandArgs(storageConfig, runtimeConfig, podmanPath, false, true, true)
+ execConfig.ExitCommand = exitCommandArgs
+
// Create and start the exec session
id, err := ctr.ExecCreate(execConfig)
if err != nil {
@@ -615,7 +629,7 @@ func (ic *ContainerEngine) ContainerExecDetached(ctx context.Context, nameOrId s
// TODO: we should try and retrieve exit code if this fails.
if err := ctr.ExecStart(id); err != nil {
- return "", err
+ return "", err
}
return id, nil
}