summaryrefslogtreecommitdiff
path: root/libpod/runtime_ctr.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-10-11 20:55:37 +0200
committerGitHub <noreply@github.com>2019-10-11 20:55:37 +0200
commit79d05b99cfee2f7841c0568fbe4def4fbc095c5c (patch)
treedce255b558c740c7f22b931e6258089c7a525a68 /libpod/runtime_ctr.go
parentcee6478f9e5e5cdbfe3df8f4894e416e4c5926e4 (diff)
parentb6a7d88397c95a9f3a462274a890b65faafd4d7a (diff)
downloadpodman-79d05b99cfee2f7841c0568fbe4def4fbc095c5c.tar.gz
podman-79d05b99cfee2f7841c0568fbe4def4fbc095c5c.tar.bz2
podman-79d05b99cfee2f7841c0568fbe4def4fbc095c5c.zip
Merge pull request #4220 from mheon/null_runtime
Move OCI runtime implementation behind an interface
Diffstat (limited to 'libpod/runtime_ctr.go')
-rw-r--r--libpod/runtime_ctr.go24
1 files changed, 16 insertions, 8 deletions
diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go
index 78176a400..411264d25 100644
--- a/libpod/runtime_ctr.go
+++ b/libpod/runtime_ctr.go
@@ -102,7 +102,7 @@ func (r *Runtime) initContainerVariables(rSpec *spec.Spec, config *ContainerConf
ctr.config.StopTimeout = define.CtrRemoveTimeout
- ctr.config.OCIRuntime = r.defaultOCIRuntime.name
+ ctr.config.OCIRuntime = r.defaultOCIRuntime.Name()
// Set namespace based on current runtime namespace
// Do so before options run so they can override it
@@ -167,8 +167,8 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (c *Contai
// Check NoCgroups support
if ctr.config.NoCgroups {
- if !ctr.ociRuntime.supportsNoCgroups {
- return nil, errors.Wrapf(define.ErrInvalidArg, "requested OCI runtime %s is not compatible with NoCgroups", ctr.ociRuntime.name)
+ if !ctr.ociRuntime.SupportsNoCgroups() {
+ return nil, errors.Wrapf(define.ErrInvalidArg, "requested OCI runtime %s is not compatible with NoCgroups", ctr.ociRuntime.Name())
}
}
@@ -264,6 +264,14 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (c *Contai
g.RemoveMount("/etc/hosts")
g.RemoveMount("/run/.containerenv")
g.RemoveMount("/run/secrets")
+
+ // Regenerate CGroup paths so they don't point to the old
+ // container ID.
+ cgroupPath, err := ctr.getOCICgroupPath()
+ if err != nil {
+ return nil, err
+ }
+ g.SetLinuxCgroupsPath(cgroupPath)
}
// Set up storage for the container
@@ -430,7 +438,7 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force bool,
}
if c.state.State == define.ContainerStatePaused {
- if err := c.ociRuntime.killContainer(c, 9); err != nil {
+ if err := c.ociRuntime.KillContainer(c, 9, false); err != nil {
return err
}
if err := c.unpause(); err != nil {
@@ -444,15 +452,15 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force bool,
// Check that the container's in a good state to be removed
if c.state.State == define.ContainerStateRunning {
- if err := c.stop(c.StopTimeout()); err != nil {
+ if err := c.stop(c.StopTimeout(), true); err != nil {
return errors.Wrapf(err, "cannot remove container %s as it could not be stopped", c.ID())
}
}
// Check that all of our exec sessions have finished
- if len(c.state.ExecSessions) != 0 {
- if err := c.ociRuntime.execStopContainer(c, c.StopTimeout()); err != nil {
- return err
+ for _, session := range c.state.ExecSessions {
+ if err := c.ociRuntime.ExecStopContainer(c, session.ID, c.StopTimeout()); err != nil {
+ return errors.Wrapf(err, "error stopping exec session %s of container %s", session.ID, c.ID())
}
}