summaryrefslogtreecommitdiff
path: root/cmd/podman/batchcontainer/container.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman/batchcontainer/container.go')
-rw-r--r--cmd/podman/batchcontainer/container.go48
1 files changed, 29 insertions, 19 deletions
diff --git a/cmd/podman/batchcontainer/container.go b/cmd/podman/batchcontainer/container.go
index 6f002f58a..017837a96 100644
--- a/cmd/podman/batchcontainer/container.go
+++ b/cmd/podman/batchcontainer/container.go
@@ -35,13 +35,13 @@ type PsOptions struct {
// BatchContainerStruct is the return obkect from BatchContainer and contains
// container related information
type BatchContainerStruct struct {
- ConConfig *libpod.ContainerConfig
- ConState libpod.ContainerStatus
- ExitCode int32
- Exited bool
- Pid int
- RootFsSize, RwSize int64
- StartedTime time.Time
+ ConConfig *libpod.ContainerConfig
+ ConState libpod.ContainerStatus
+ ExitCode int32
+ Exited bool
+ Pid int
+ StartedTime time.Time
+ Size *ContainerSize
}
// Namespace describes output for ps namespace
@@ -56,18 +56,25 @@ type Namespace struct {
UTS string `json:"uts,omitempty"`
}
+// ContainerSize holds the size of the container's root filesystem and top
+// read-write layer
+type ContainerSize struct {
+ RootFsSize int64 `json:"rootFsSize"`
+ RwSize int64 `json:"rwSize"`
+}
+
// BatchContainer is used in ps to reduce performance hits by "batching"
// locks.
func BatchContainerOp(ctr *libpod.Container, opts PsOptions) (BatchContainerStruct, error) {
var (
- conConfig *libpod.ContainerConfig
- conState libpod.ContainerStatus
- err error
- exitCode int32
- exited bool
- pid int
- rootFsSize, rwSize int64
- startedTime time.Time
+ conConfig *libpod.ContainerConfig
+ conState libpod.ContainerStatus
+ err error
+ exitCode int32
+ exited bool
+ pid int
+ size *ContainerSize
+ startedTime time.Time
)
batchErr := ctr.Batch(func(c *libpod.Container) error {
@@ -97,16 +104,20 @@ func BatchContainerOp(ctr *libpod.Container, opts PsOptions) (BatchContainerStru
}
}
if opts.Size {
- rootFsSize, err = c.RootFsSize()
+ size = new(ContainerSize)
+
+ rootFsSize, err := c.RootFsSize()
if err != nil {
logrus.Errorf("error getting root fs size for %q: %v", c.ID(), err)
}
- rwSize, err = c.RWSize()
+ rwSize, err := c.RWSize()
if err != nil {
logrus.Errorf("error getting rw size for %q: %v", c.ID(), err)
}
+ size.RootFsSize = rootFsSize
+ size.RwSize = rwSize
}
return nil
})
@@ -119,9 +130,8 @@ func BatchContainerOp(ctr *libpod.Container, opts PsOptions) (BatchContainerStru
ExitCode: exitCode,
Exited: exited,
Pid: pid,
- RootFsSize: rootFsSize,
- RwSize: rwSize,
StartedTime: startedTime,
+ Size: size,
}, nil
}