mirror of https://github.com/containers/podman.git
Replace usage of runc with runtime
Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #412 Approved by: baude
This commit is contained in:
parent
fa5f99effa
commit
c5dc7f81fc
|
@ -466,7 +466,7 @@ func (c *Container) CgroupParent() string {
|
||||||
|
|
||||||
// LogPath returns the path to the container's log file
|
// LogPath returns the path to the container's log file
|
||||||
// This file will only be present after Init() is called to create the container
|
// This file will only be present after Init() is called to create the container
|
||||||
// in runc
|
// in the runtime
|
||||||
func (c *Container) LogPath() string {
|
func (c *Container) LogPath() string {
|
||||||
return c.config.LogPath
|
return c.config.LogPath
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ func (c *Container) Init() (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("Created container %s in runc", c.ID())
|
logrus.Debugf("Created container %s in OCI runtime", c.ID())
|
||||||
|
|
||||||
c.state.State = ContainerStateCreated
|
c.state.State = ContainerStateCreated
|
||||||
|
|
||||||
|
@ -275,10 +275,11 @@ func (c *Container) Exec(tty, privileged bool, env, cmd []string, user string) e
|
||||||
pidFile := c.execPidPath(sessionID)
|
pidFile := c.execPidPath(sessionID)
|
||||||
const pidWaitTimeout = 250
|
const pidWaitTimeout = 250
|
||||||
|
|
||||||
// Wait until runc makes the pidfile
|
// Wait until the runtime makes the pidfile
|
||||||
// TODO: If runc errors before the PID file is created, we have to wait for timeout here
|
// TODO: If runtime errors before the PID file is created, we have to
|
||||||
|
// wait for timeout here
|
||||||
if err := WaitForFile(pidFile, pidWaitTimeout*time.Millisecond); err != nil {
|
if err := WaitForFile(pidFile, pidWaitTimeout*time.Millisecond); err != nil {
|
||||||
logrus.Debugf("Timed out waiting for pidfile from runc for container %s exec", c.ID())
|
logrus.Debugf("Timed out waiting for pidfile from runtime for container %s exec", c.ID())
|
||||||
|
|
||||||
// Check if an error occurred in the process before we made a pidfile
|
// Check if an error occurred in the process before we made a pidfile
|
||||||
// TODO: Wait() here is a poor choice - is there a way to see if
|
// TODO: Wait() here is a poor choice - is there a way to see if
|
||||||
|
@ -287,7 +288,7 @@ func (c *Container) Exec(tty, privileged bool, env, cmd []string, user string) e
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return errors.Wrapf(err, "timed out waiting for runc to create pidfile for exec session in container %s", c.ID())
|
return errors.Wrapf(err, "timed out waiting for runtime to create pidfile for exec session in container %s", c.ID())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pidfile exists, read it
|
// Pidfile exists, read it
|
||||||
|
@ -693,7 +694,7 @@ func (c *Container) Sync() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// If runc knows about the container, update its status in runc
|
// If runtime knows about the container, update its status in runtime
|
||||||
// And then save back to disk
|
// And then save back to disk
|
||||||
if (c.state.State != ContainerStateUnknown) &&
|
if (c.state.State != ContainerStateUnknown) &&
|
||||||
(c.state.State != ContainerStateConfigured) {
|
(c.state.State != ContainerStateConfigured) {
|
||||||
|
|
|
@ -105,7 +105,7 @@ func (c *Container) execPidPath(sessionID string) string {
|
||||||
return filepath.Join(c.state.RunDir, "exec_pid_"+sessionID)
|
return filepath.Join(c.state.RunDir, "exec_pid_"+sessionID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sync this container with on-disk state and runc status
|
// Sync this container with on-disk state and runtime status
|
||||||
// Should only be called with container lock held
|
// Should only be called with container lock held
|
||||||
// This function should suffice to ensure a container's state is accurate and
|
// This function should suffice to ensure a container's state is accurate and
|
||||||
// it is valid for use.
|
// it is valid for use.
|
||||||
|
@ -113,7 +113,7 @@ func (c *Container) syncContainer() error {
|
||||||
if err := c.runtime.state.UpdateContainer(c); err != nil {
|
if err := c.runtime.state.UpdateContainer(c); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// If runc knows about the container, update its status in runc
|
// If runtime knows about the container, update its status in runtime
|
||||||
// And then save back to disk
|
// And then save back to disk
|
||||||
if (c.state.State != ContainerStateUnknown) &&
|
if (c.state.State != ContainerStateUnknown) &&
|
||||||
(c.state.State != ContainerStateConfigured) {
|
(c.state.State != ContainerStateConfigured) {
|
||||||
|
|
|
@ -36,7 +36,8 @@ const (
|
||||||
// ContainerCreateTimeout represents the value of container creating timeout
|
// ContainerCreateTimeout represents the value of container creating timeout
|
||||||
ContainerCreateTimeout = 240 * time.Second
|
ContainerCreateTimeout = 240 * time.Second
|
||||||
|
|
||||||
// Timeout before declaring that runc has failed to kill a given container
|
// Timeout before declaring that runtime has failed to kill a given
|
||||||
|
// container
|
||||||
killContainerTimeout = 5 * time.Second
|
killContainerTimeout = 5 * time.Second
|
||||||
// DefaultShmSize is the default shm size
|
// DefaultShmSize is the default shm size
|
||||||
DefaultShmSize = 64 * 1024 * 1024
|
DefaultShmSize = 64 * 1024 * 1024
|
||||||
|
@ -299,7 +300,7 @@ func (r *OCIRuntime) createContainer(ctr *Container, cgroupParent string) (err e
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err2 := r.deleteContainer(ctr); err2 != nil {
|
if err2 := r.deleteContainer(ctr); err2 != nil {
|
||||||
logrus.Errorf("Error removing container %s from runc after creation failed", ctr.ID())
|
logrus.Errorf("Error removing container %s from runtime after creation failed", ctr.ID())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -366,7 +367,7 @@ func (r *OCIRuntime) updateContainerStatus(ctr *Container) error {
|
||||||
case "stopped":
|
case "stopped":
|
||||||
ctr.state.State = ContainerStateStopped
|
ctr.state.State = ContainerStateStopped
|
||||||
default:
|
default:
|
||||||
return errors.Wrapf(ErrInternal, "unrecognized status returned by runc for container %s: %s",
|
return errors.Wrapf(ErrInternal, "unrecognized status returned by runtime for container %s: %s",
|
||||||
ctr.ID(), state.Status)
|
ctr.ID(), state.Status)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,7 +478,7 @@ func (r *OCIRuntime) stopContainer(ctr *Container, timeout uint) error {
|
||||||
return errors.Wrapf(err, "error sending SIGKILL to container %s", ctr.ID())
|
return errors.Wrapf(err, "error sending SIGKILL to container %s", ctr.ID())
|
||||||
}
|
}
|
||||||
|
|
||||||
// Give runc a few seconds to make it happen
|
// Give runtime a few seconds to make it happen
|
||||||
if err := waitContainerStop(ctr, killContainerTimeout); err != nil {
|
if err := waitContainerStop(ctr, killContainerTimeout); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -485,7 +486,7 @@ func (r *OCIRuntime) stopContainer(ctr *Container, timeout uint) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// deleteContainer deletes a container from runc
|
// deleteContainer deletes a container from the OCI runtime
|
||||||
func (r *OCIRuntime) deleteContainer(ctr *Container) error {
|
func (r *OCIRuntime) deleteContainer(ctr *Container) error {
|
||||||
_, err := utils.ExecCmd(r.path, "delete", "--force", ctr.ID())
|
_, err := utils.ExecCmd(r.path, "delete", "--force", ctr.ID())
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -162,11 +162,11 @@ func (r *Runtime) RemovePod(p *Pod, removeCtrs, force bool) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete the container from runc (only if we are not
|
// Delete the container from runtime (only if we are not
|
||||||
// ContainerStateConfigured)
|
// ContainerStateConfigured)
|
||||||
if ctr.state.State != ContainerStateConfigured {
|
if ctr.state.State != ContainerStateConfigured {
|
||||||
if err := r.ociRuntime.deleteContainer(ctr); err != nil {
|
if err := r.ociRuntime.deleteContainer(ctr); err != nil {
|
||||||
return errors.Wrapf(err, "error removing container %s from runc", ctr.ID())
|
return errors.Wrapf(err, "error removing container %s from runtime", ctr.ID())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue