summaryrefslogtreecommitdiff
path: root/libpod/container.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2017-11-07 13:46:30 -0500
committerMatthew Heon <matthew.heon@gmail.com>2017-11-18 12:54:05 -0500
commitc6fe4430b76ceeecd6b0b609cca8e705921db0c4 (patch)
tree2b2b85f120001df77ee5133dc8c4ae3655519324 /libpod/container.go
parent3b72af614777b966671ad0eb0c5dbde0eeedcfa2 (diff)
downloadpodman-c6fe4430b76ceeecd6b0b609cca8e705921db0c4.tar.gz
podman-c6fe4430b76ceeecd6b0b609cca8e705921db0c4.tar.bz2
podman-c6fe4430b76ceeecd6b0b609cca8e705921db0c4.zip
Compile-tested implementation of SQL-backed state
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Diffstat (limited to 'libpod/container.go')
-rw-r--r--libpod/container.go74
1 files changed, 20 insertions, 54 deletions
diff --git a/libpod/container.go b/libpod/container.go
index 8e84a1f3e..bef3f1088 100644
--- a/libpod/container.go
+++ b/libpod/container.go
@@ -87,21 +87,17 @@ type containerConfig struct {
Spec *spec.Spec `json:"spec"`
ID string `json:"id"`
Name string `json:"name"`
- // RootfsFromImage indicates whether the container uses a root
- // filesystem from an image, or from a user-provided directory
- RootfsFromImage bool
- // Directory used as a root filesystem if not configured with an image
- RootfsDir string `json:"rootfsDir,omitempty"`
// Information on the image used for the root filesystem
RootfsImageID string `json:"rootfsImageID,omitempty"`
RootfsImageName string `json:"rootfsImageName,omitempty"`
- MountLabel string `json:"MountLabel,omitempty"`
UseImageConfig bool `json:"useImageConfig"`
- // Whether to keep container STDIN open
- Stdin bool
+ // SELinux mount label for root filesystem
+ MountLabel string `json:"MountLabel,omitempty"`
// Static directory for container content that will persist across
// reboot
StaticDir string `json:"staticDir"`
+ // Whether to keep container STDIN open
+ Stdin bool
// Pod the container belongs to
Pod string `json:"pod,omitempty"`
// Labels is a set of key-value pairs providing additional information
@@ -207,18 +203,6 @@ func (c *Container) setupStorage() error {
return errors.Wrapf(ErrCtrStateInvalid, "container %s must be in Configured state to have storage set up", c.ID())
}
- // If we're configured to use a directory, perform that setup
- if !c.config.RootfsFromImage {
- // TODO implement directory-based root filesystems
- return ErrNotImplemented
- }
-
- // Not using a directory, so call into containers/storage
- return c.setupImageRootfs()
-}
-
-// Set up an image as root filesystem using containers/storage
-func (c *Container) setupImageRootfs() error {
// Need both an image ID and image name, plus a bool telling us whether to use the image configuration
if c.config.RootfsImageID == "" || c.config.RootfsImageName == "" {
return errors.Wrapf(ErrInvalidArg, "must provide image ID and image name to use an image")
@@ -248,16 +232,6 @@ func (c *Container) teardownStorage() error {
return errors.Wrapf(ErrCtrStateInvalid, "cannot remove storage for container %s as it is running or paused", c.ID())
}
- if !c.config.RootfsFromImage {
- // TODO implement directory-based root filesystems
- return ErrNotImplemented
- }
-
- return c.teardownImageRootfs()
-}
-
-// Completely remove image-based root filesystem for a container
-func (c *Container) teardownImageRootfs() error {
if c.state.Mounted {
if err := c.runtime.storageService.StopContainer(c.ID()); err != nil {
return errors.Wrapf(err, "error unmounting container %s root filesystem", c.ID())
@@ -286,33 +260,25 @@ func (c *Container) Create() (err error) {
return errors.Wrapf(ErrCtrExists, "container %s has already been created in runtime", c.ID())
}
- // If using containers/storage, mount the container
- if !c.config.RootfsFromImage {
- // TODO implement directory-based root filesystems
- if !c.state.Mounted {
- return ErrNotImplemented
- }
- } else {
- mountPoint, err := c.runtime.storageService.StartContainer(c.ID())
- if err != nil {
- return errors.Wrapf(err, "error mounting storage for container %s", c.ID())
- }
- c.state.Mounted = true
- c.state.Mountpoint = mountPoint
-
- logrus.Debugf("Created root filesystem for container %s at %s", c.ID(), c.state.Mountpoint)
+ mountPoint, err := c.runtime.storageService.StartContainer(c.ID())
+ if err != nil {
+ return errors.Wrapf(err, "error mounting storage for container %s", c.ID())
+ }
+ c.state.Mounted = true
+ c.state.Mountpoint = mountPoint
- defer func() {
- if err != nil {
- if err2 := c.runtime.storageService.StopContainer(c.ID()); err2 != nil {
- logrus.Errorf("Error unmounting storage for container %s: %v", c.ID(), err2)
- }
+ logrus.Debugf("Created root filesystem for container %s at %s", c.ID(), c.state.Mountpoint)
- c.state.Mounted = false
- c.state.Mountpoint = ""
+ defer func() {
+ if err != nil {
+ if err2 := c.runtime.storageService.StopContainer(c.ID()); err2 != nil {
+ logrus.Errorf("Error unmounting storage for container %s: %v", c.ID(), err2)
}
- }()
- }
+
+ c.state.Mounted = false
+ c.state.Mountpoint = ""
+ }
+ }()
// Make the OCI runtime spec we will use
c.runningSpec = new(spec.Spec)