aboutsummaryrefslogtreecommitdiff
path: root/libpod/runtime_pod_infra_linux.go
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2020-08-10 15:00:42 -0400
committerMatthew Heon <mheon@redhat.com>2020-08-13 14:03:57 -0400
commita0719398931d59a422835b7e4cc7b6e28c18d031 (patch)
tree4a8e1f58e21946d71b0b48864f28d605aa2a5d9d /libpod/runtime_pod_infra_linux.go
parent6d3075a6c79a6e761c183e0d5e6aa239fad21b63 (diff)
downloadpodman-a0719398931d59a422835b7e4cc7b6e28c18d031.tar.gz
podman-a0719398931d59a422835b7e4cc7b6e28c18d031.tar.bz2
podman-a0719398931d59a422835b7e4cc7b6e28c18d031.zip
Ensure pod infra containers have an exit command
Most Libpod containers are made via `pkg/specgen/generate` which includes code to generate an appropriate exit command which will handle unmounting the container's storage, cleaning up the container's network, etc. There is one notable exception: pod infra containers, which are made entirely within Libpod and do not touch pkg/specgen. As such, no cleanup process, network never cleaned up, bad things can happen. There is good news, though - it's not that difficult to add this, and it's done in this PR. Generally speaking, we don't allow passing options directly to the infra container at create time, but we do (optionally) proxy a pre-approved set of options into it when we create it. Add ExitCommand to these options, and set it at time of pod creation using the same code we use to generate exit commands for normal containers. Fixes #7103 Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'libpod/runtime_pod_infra_linux.go')
-rw-r--r--libpod/runtime_pod_infra_linux.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/libpod/runtime_pod_infra_linux.go b/libpod/runtime_pod_infra_linux.go
index 4d149a6eb..b2f21d946 100644
--- a/libpod/runtime_pod_infra_linux.go
+++ b/libpod/runtime_pod_infra_linux.go
@@ -83,6 +83,9 @@ func (r *Runtime) makeInfraContainer(ctx context.Context, p *Pod, imgName, rawIm
return nil, errors.Wrapf(err, "error removing network namespace from pod %s infra container", p.ID())
}
+ // For each option in InfraContainerConfig - if set, pass into
+ // the infra container we're creating with the appropriate
+ // With... option.
if p.config.InfraContainer.StaticIP != nil {
options = append(options, WithStaticIP(p.config.InfraContainer.StaticIP))
}
@@ -107,6 +110,9 @@ func (r *Runtime) makeInfraContainer(ctx context.Context, p *Pod, imgName, rawIm
if len(p.config.InfraContainer.HostAdd) > 0 {
options = append(options, WithHosts(p.config.InfraContainer.HostAdd))
}
+ if len(p.config.InfraContainer.ExitCommand) > 0 {
+ options = append(options, WithExitCommand(p.config.InfraContainer.ExitCommand))
+ }
}
g.SetRootReadonly(true)