summaryrefslogtreecommitdiff
path: root/pkg/domain
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/domain')
-rw-r--r--pkg/domain/entities/engine.go1
-rw-r--r--pkg/domain/entities/play.go2
-rw-r--r--pkg/domain/infra/abi/manifest.go2
-rw-r--r--pkg/domain/infra/abi/system.go70
-rw-r--r--pkg/domain/infra/runtime_libpod.go8
-rw-r--r--pkg/domain/infra/tunnel/containers.go7
6 files changed, 30 insertions, 60 deletions
diff --git a/pkg/domain/entities/engine.go b/pkg/domain/entities/engine.go
index 6776d09e9..f23d964e5 100644
--- a/pkg/domain/entities/engine.go
+++ b/pkg/domain/entities/engine.go
@@ -46,6 +46,7 @@ type PodmanConfig struct {
RegistriesConf string // allows for specifying a custom registries.conf
Remote bool // Connection to Podman API Service will use RESTful API
RuntimePath string // --runtime flag will set Engine.RuntimePath
+ RuntimeFlags []string // global flags for the container runtime
Span opentracing.Span // tracing object
SpanCloser io.Closer // Close() for tracing object
SpanCtx context.Context // context to use when tracing
diff --git a/pkg/domain/entities/play.go b/pkg/domain/entities/play.go
index 0823bc64e..2ba369b83 100644
--- a/pkg/domain/entities/play.go
+++ b/pkg/domain/entities/play.go
@@ -32,7 +32,7 @@ type PlayKubePod struct {
ID string
// Containers - the IDs of the containers running in the created pod.
Containers []string
- // Logs - non-fatal erros and log messages while processing.
+ // Logs - non-fatal errors and log messages while processing.
Logs []string
}
diff --git a/pkg/domain/infra/abi/manifest.go b/pkg/domain/infra/abi/manifest.go
index 55f73bf65..672d0a69f 100644
--- a/pkg/domain/infra/abi/manifest.go
+++ b/pkg/domain/infra/abi/manifest.go
@@ -130,7 +130,7 @@ func (ir *ImageEngine) ManifestAdd(ctx context.Context, opts entities.ManifestAd
func (ir *ImageEngine) ManifestAnnotate(ctx context.Context, names []string, opts entities.ManifestAnnotateOptions) (string, error) {
listImage, err := ir.Libpod.ImageRuntime().NewFromLocal(names[0])
if err != nil {
- return "", errors.Wrapf(err, "error retreiving local image from image name %s", names[0])
+ return "", errors.Wrapf(err, "error retrieving local image from image name %s", names[0])
}
digest, err := digest.Parse(names[1])
if err != nil {
diff --git a/pkg/domain/infra/abi/system.go b/pkg/domain/infra/abi/system.go
index 914a7681d..57c098166 100644
--- a/pkg/domain/infra/abi/system.go
+++ b/pkg/domain/infra/abi/system.go
@@ -17,7 +17,6 @@ import (
"github.com/containers/podman/v2/pkg/rootless"
"github.com/containers/podman/v2/pkg/util"
"github.com/containers/podman/v2/utils"
- "github.com/docker/distribution/reference"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
@@ -199,71 +198,32 @@ func (ic *ContainerEngine) SystemDf(ctx context.Context, options entities.System
dfImages = []*entities.SystemDfImageReport{}
)
- // Get Images and iterate them
+ // Compute disk-usage stats for all local images.
imgs, err := ic.Libpod.ImageRuntime().GetImages()
if err != nil {
return nil, err
}
- for _, i := range imgs {
- var sharedSize uint64
- cons, err := i.Containers()
- if err != nil {
- return nil, err
- }
- imageSize, err := i.Size(ctx)
- if err != nil {
- return nil, err
- }
- uniqueSize := *imageSize
- parent, err := i.GetParent(ctx)
- if err != nil {
- return nil, err
- }
- if parent != nil {
- parentSize, err := parent.Size(ctx)
- if err != nil {
- return nil, err
- }
- uniqueSize = *parentSize - *imageSize
- sharedSize = *imageSize - uniqueSize
- }
- var name, repository, tag string
- for _, n := range i.Names() {
- if len(n) > 0 {
- name = n
- break
- }
- }
-
- if len(name) > 0 {
- named, err := reference.ParseNormalizedNamed(name)
- if err != nil {
- return nil, err
- }
- repository = named.Name()
- if tagged, isTagged := named.(reference.NamedTagged); isTagged {
- tag = tagged.Tag()
- }
- } else {
- repository = "<none>"
- tag = "<none>"
- }
+ imageStats, err := ic.Libpod.ImageRuntime().DiskUsage(ctx, imgs)
+ if err != nil {
+ return nil, err
+ }
+ for _, stat := range imageStats {
report := entities.SystemDfImageReport{
- Repository: repository,
- Tag: tag,
- ImageID: i.ID(),
- Created: i.Created(),
- Size: int64(*imageSize),
- SharedSize: int64(sharedSize),
- UniqueSize: int64(uniqueSize),
- Containers: len(cons),
+ Repository: stat.Repository,
+ Tag: stat.Tag,
+ ImageID: stat.ID,
+ Created: stat.Created,
+ Size: int64(stat.Size),
+ SharedSize: int64(stat.SharedSize),
+ UniqueSize: int64(stat.UniqueSize),
+ Containers: stat.Containers,
}
dfImages = append(dfImages, &report)
}
- // GetContainers and iterate them
+ // Get Containers and iterate them
cons, err := ic.Libpod.GetAllContainers()
if err != nil {
return nil, err
diff --git a/pkg/domain/infra/runtime_libpod.go b/pkg/domain/infra/runtime_libpod.go
index a88347e24..f9b8106ef 100644
--- a/pkg/domain/infra/runtime_libpod.go
+++ b/pkg/domain/infra/runtime_libpod.go
@@ -156,6 +156,14 @@ func getRuntime(ctx context.Context, fs *flag.FlagSet, opts *engineOpts) (*libpo
options = append(options, libpod.WithRenumber())
}
+ if len(cfg.RuntimeFlags) > 0 {
+ runtimeFlags := []string{}
+ for _, arg := range cfg.RuntimeFlags {
+ runtimeFlags = append(runtimeFlags, "--"+arg)
+ }
+ options = append(options, libpod.WithRuntimeFlags(runtimeFlags))
+ }
+
// Only set this if the user changes storage config on the command line
if storageSet {
options = append(options, libpod.WithStorageConfig(storageOpts))
diff --git a/pkg/domain/infra/tunnel/containers.go b/pkg/domain/infra/tunnel/containers.go
index 062b38a70..35550b9be 100644
--- a/pkg/domain/infra/tunnel/containers.go
+++ b/pkg/domain/infra/tunnel/containers.go
@@ -19,6 +19,7 @@ import (
"github.com/containers/podman/v2/pkg/bindings"
"github.com/containers/podman/v2/pkg/bindings/containers"
"github.com/containers/podman/v2/pkg/domain/entities"
+ "github.com/containers/podman/v2/pkg/errorhandling"
"github.com/containers/podman/v2/pkg/specgen"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
@@ -537,8 +538,8 @@ func (ic *ContainerEngine) ContainerRun(ctx context.Context, opts entities.Conta
// de-spaghetti the code.
defer func() {
if err := containers.Remove(ic.ClientCxt, con.ID, bindings.PFalse, bindings.PTrue); err != nil {
- if errors.Cause(err) == define.ErrNoSuchCtr ||
- errors.Cause(err) == define.ErrCtrRemoved {
+ if errorhandling.Contains(err, define.ErrNoSuchCtr) ||
+ errorhandling.Contains(err, define.ErrCtrRemoved) {
logrus.Warnf("Container %s does not exist: %v", con.ID, err)
} else {
logrus.Errorf("Error removing container %s: %v", con.ID, err)
@@ -556,7 +557,7 @@ func (ic *ContainerEngine) ContainerRun(ctx context.Context, opts entities.Conta
// Determine why the wait failed. If the container doesn't exist,
// consult the events.
- if !strings.Contains(waitErr.Error(), define.ErrNoSuchCtr.Error()) {
+ if !errorhandling.Contains(waitErr, define.ErrNoSuchCtr) {
return &report, waitErr
}