diff options
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container.go | 24 | ||||
-rw-r--r-- | libpod/container_inspect.go | 3 | ||||
-rw-r--r-- | libpod/oci.go | 3 | ||||
-rw-r--r-- | libpod/runtime_img.go | 28 |
4 files changed, 37 insertions, 21 deletions
diff --git a/libpod/container.go b/libpod/container.go index 4170ea443..27042de39 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -515,3 +515,27 @@ func (c *Container) CGroupPath() cgroups.Path { func (c *Container) StopTimeout() uint { return c.config.StopTimeout } + +// RootFsSize returns the root FS size of the container +func (c *Container) RootFsSize() (int64, error) { + if !c.locked { + c.lock.Lock() + defer c.lock.Unlock() + if err := c.syncContainer(); err != nil { + return -1, errors.Wrapf(err, "error updating container %s state", c.ID()) + } + } + return c.rootFsSize() +} + +// RWSize returns the rw size of the container +func (c *Container) RWSize() (int64, error) { + if !c.locked { + c.lock.Lock() + defer c.lock.Unlock() + if err := c.syncContainer(); err != nil { + return -1, errors.Wrapf(err, "error updating container %s state", c.ID()) + } + } + return c.rwSize() +} diff --git a/libpod/container_inspect.go b/libpod/container_inspect.go index 0bb45cedd..78dd00c16 100644 --- a/libpod/container_inspect.go +++ b/libpod/container_inspect.go @@ -4,7 +4,6 @@ import ( "github.com/cri-o/ocicni/pkg/ocicni" "github.com/projectatomic/libpod/libpod/driver" "github.com/sirupsen/logrus" - "github.com/ulule/deepcopier" ) func (c *Container) getContainerInspectData(size bool, driverData *driver.Data) (*ContainerInspectData, error) { @@ -77,7 +76,7 @@ func (c *Container) getContainerInspectData(size bool, driverData *driver.Data) // Copy port mappings into network settings if config.PortMappings != nil { - deepcopier.Copy(config.PortMappings).To(data.NetworkSettings.Ports) + data.NetworkSettings.Ports = config.PortMappings } // Get information on the container's network namespace (if present) diff --git a/libpod/oci.go b/libpod/oci.go index c122071e3..155b23640 100644 --- a/libpod/oci.go +++ b/libpod/oci.go @@ -232,11 +232,8 @@ func (r *OCIRuntime) createContainer(ctr *Container, cgroupParent string) (err e if err != nil { logrus.Warnf("Failed to add conmon to cgroupfs sandbox cgroup: %v", err) } else { - // XXX: this defer does nothing as the cgroup can't be deleted cause - // it contains the conmon pid in tasks // we need to remove this defer and delete the cgroup once conmon exits // maybe need a conmon monitor? - defer control.Delete() if err := control.Add(cgroups.Process{Pid: cmd.Process.Pid}); err != nil { logrus.Warnf("Failed to add conmon to cgroupfs sandbox cgroup: %v", err) } diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go index 671e08c19..882174856 100644 --- a/libpod/runtime_img.go +++ b/libpod/runtime_img.go @@ -342,27 +342,23 @@ func getTags(nameInput string) (reference.NamedTagged, bool, error) { return tagged, isTagged, nil } -// GetLocalImageName returns the name of the image if it is local. -// It will return an empty string and error if not found. -func (k *Image) GetLocalImageName() (string, error) { - _, err := k.runtime.GetImage(k.Name) +// GetLocalImageName returns the name of the image if it is local as well +// as the image's ID. It will return an empty strings and error if not found. +func (k *Image) GetLocalImageName() (string, string, error) { + localImage, err := k.runtime.GetImage(k.Name) if err == nil { k.LocalName = k.Name - return k.Name, nil + return k.Name, localImage.ID, nil } localImages, err := k.runtime.GetImages(&ImageFilterParams{}) if err != nil { - return "", errors.Wrapf(err, "unable to find local images") + return "", "", errors.Wrapf(err, "unable to find local images") } _, isTagged, err := getTags(k.Name) if err != nil { - return "", err + return "", "", err } for _, image := range localImages { - if strings.HasPrefix(image.ID, k.Name) { - k.ID = image.ID - return image.ID, nil - } for _, name := range image.Names { imgRef, err := reference.Parse(name) if err != nil { @@ -382,22 +378,22 @@ func (k *Image) GetLocalImageName() (string, error) { if imageName == k.Name { k.LocalName = name - return name, nil + return name, image.ID, nil } imageSplit := strings.Split(imageName, "/") baseName := imageSplit[len(imageSplit)-1] if baseName == k.Name { k.LocalName = name - return name, nil + return name, image.ID, nil } } } - return "", errors.Wrapf(storage.ErrImageUnknown, "unable to find image locally") + return "", "", errors.Wrapf(storage.ErrImageUnknown, "unable to find image locally") } // HasLatest determines if we have the latest image local func (k *Image) HasLatest() (bool, error) { - localName, err := k.GetLocalImageName() + localName, _, err := k.GetLocalImageName() if err != nil { return false, err } @@ -434,7 +430,7 @@ func (k *Image) Pull(writer io.Writer) error { func (k *Image) Remove(force bool) (string, error) { if k.LocalName == "" { // This populates the images local name - _, err := k.GetLocalImageName() + _, _, err := k.GetLocalImageName() if err != nil { return "", errors.Wrapf(err, "unable to find %s locally", k.Name) } |