summaryrefslogtreecommitdiff
path: root/cmd/podman/shared
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman/shared')
-rw-r--r--cmd/podman/shared/container.go33
-rw-r--r--cmd/podman/shared/create.go9
-rw-r--r--cmd/podman/shared/create_cli.go14
3 files changed, 31 insertions, 25 deletions
diff --git a/cmd/podman/shared/container.go b/cmd/podman/shared/container.go
index 4f2002992..5f8df2e10 100644
--- a/cmd/podman/shared/container.go
+++ b/cmd/podman/shared/container.go
@@ -76,6 +76,7 @@ type PsContainerOutput struct {
Pid int
Size *ContainerSize
Pod string
+ PodName string
CreatedAt time.Time
ExitedAt time.Time
StartedAt time.Time
@@ -112,7 +113,7 @@ type ContainerSize struct {
// NewBatchContainer runs a batch process under one lock to get container information and only
// be called in PBatch.
-func NewBatchContainer(ctr *libpod.Container, opts PsOptions) (PsContainerOutput, error) {
+func NewBatchContainer(r *libpod.Runtime, ctr *libpod.Container, opts PsOptions) (PsContainerOutput, error) {
var (
conState define.ContainerStatus
command string
@@ -204,11 +205,11 @@ func NewBatchContainer(ctr *libpod.Container, opts PsOptions) (PsContainerOutput
_, imageName := ctr.Image()
cid := ctr.ID()
- pod := ctr.PodID()
+ podID := ctr.PodID()
if !opts.NoTrunc {
cid = cid[0:cidTruncLength]
- if len(pod) > podTruncLength {
- pod = pod[0:podTruncLength]
+ if len(podID) > podTruncLength {
+ podID = podID[0:podTruncLength]
}
if len(command) > cmdTruncLength {
command = command[0:cmdTruncLength] + "..."
@@ -231,13 +232,29 @@ func NewBatchContainer(ctr *libpod.Container, opts PsOptions) (PsContainerOutput
pso.State = conState
pso.Pid = pid
pso.Size = size
- pso.Pod = pod
pso.ExitedAt = exitedAt
pso.CreatedAt = ctr.CreatedTime()
pso.StartedAt = startedAt
pso.Labels = ctr.Labels()
pso.Mounts = strings.Join(ctr.UserVolumes(), " ")
+ // Add pod name and pod ID if requested by user.
+ // No need to look up the pod if its ID is empty.
+ if opts.Pod && len(podID) > 0 {
+ // The pod name is not in the container definition
+ // so we need to retrieve it using the pod ID.
+ var podName string
+ pod, err := r.LookupPod(podID)
+ if err != nil {
+ logrus.Errorf("unable to lookup pod for container %s", ctr.ID())
+ } else {
+ podName = pod.Name()
+ }
+
+ pso.Pod = podID
+ pso.PodName = podName
+ }
+
if opts.Namespace {
pso.Cgroup = ns.Cgroup
pso.IPC = ns.IPC
@@ -462,13 +479,13 @@ func GetPsContainerOutput(r *libpod.Runtime, opts PsOptions, filters []string, m
outputContainers = []*libpod.Container{latestCtr}
}
- pss := PBatch(outputContainers, maxWorkers, opts)
+ pss := PBatch(r, outputContainers, maxWorkers, opts)
return pss, nil
}
// PBatch performs batch operations on a container in parallel. It spawns the
// number of workers relative to the number of parallel operations desired.
-func PBatch(containers []*libpod.Container, workers int, opts PsOptions) []PsContainerOutput {
+func PBatch(r *libpod.Runtime, containers []*libpod.Container, workers int, opts PsOptions) []PsContainerOutput {
var wg sync.WaitGroup
psResults := []PsContainerOutput{}
@@ -492,7 +509,7 @@ func PBatch(containers []*libpod.Container, workers int, opts PsOptions) []PsCon
j := j
wg.Add(1)
f := func() (PsContainerOutput, error) {
- return NewBatchContainer(j, opts)
+ return NewBatchContainer(r, j, opts)
}
jobs <- workerInput{
parallelFunc: f,
diff --git a/cmd/podman/shared/create.go b/cmd/podman/shared/create.go
index bb4e9cd12..58cf56eea 100644
--- a/cmd/podman/shared/create.go
+++ b/cmd/podman/shared/create.go
@@ -24,7 +24,6 @@ import (
"github.com/containers/libpod/pkg/rootless"
cc "github.com/containers/libpod/pkg/spec"
"github.com/containers/libpod/pkg/util"
- "github.com/docker/docker/pkg/signal"
"github.com/docker/go-connections/nat"
"github.com/docker/go-units"
"github.com/opentracing/opentracing-go"
@@ -464,7 +463,7 @@ func ParseCreateOpts(ctx context.Context, c *GenericCLIResults, runtime *libpod.
signalString = c.String("stop-signal")
}
if signalString != "" {
- stopSignal, err = signal.ParseSignal(signalString)
+ stopSignal, err = util.ParseSignal(signalString)
if err != nil {
return nil, err
}
@@ -624,7 +623,7 @@ func ParseCreateOpts(ctx context.Context, c *GenericCLIResults, runtime *libpod.
}
if systemd {
if signalString == "" {
- stopSignal, err = signal.ParseSignal("RTMIN+3")
+ stopSignal, err = util.ParseSignal("RTMIN+3")
if err != nil {
return nil, errors.Wrapf(err, "error parsing systemd signal")
}
@@ -804,6 +803,10 @@ func CreateContainerFromCreateConfig(r *libpod.Runtime, createConfig *cc.CreateC
return nil, err
}
+ // Set the CreateCommand explicitly. Some (future) consumers of libpod
+ // might not want to set it.
+ options = append(options, libpod.WithCreateCommand())
+
ctr, err := r.NewContainer(ctx, runtimeSpec, options...)
if err != nil {
return nil, err
diff --git a/cmd/podman/shared/create_cli.go b/cmd/podman/shared/create_cli.go
index 08a40b206..00b83906d 100644
--- a/cmd/podman/shared/create_cli.go
+++ b/cmd/podman/shared/create_cli.go
@@ -12,11 +12,6 @@ import (
"github.com/sirupsen/logrus"
)
-const (
- // It's not kernel limit, we want this 4M limit to supply a reasonable functional container
- linuxMinMemory = 4194304
-)
-
// GetAllLabels ...
func GetAllLabels(labelFile, inputLabels []string) (map[string]string, error) {
labels := make(map[string]string)
@@ -86,9 +81,6 @@ func verifyContainerResources(config *cc.CreateConfig, update bool) ([]string, e
sysInfo := sysinfo.New(true)
// memory subsystem checks and adjustments
- if config.Resources.Memory != 0 && config.Resources.Memory < linuxMinMemory {
- return warnings, fmt.Errorf("minimum memory limit allowed is 4MB")
- }
if config.Resources.Memory > 0 && !sysInfo.MemoryLimit {
warnings = addWarning(warnings, "Your kernel does not support memory limit capabilities or the cgroup is not mounted. Limitation discarded.")
config.Resources.Memory = 0
@@ -120,9 +112,6 @@ func verifyContainerResources(config *cc.CreateConfig, update bool) ([]string, e
warnings = addWarning(warnings, "Your kernel does not support memory soft limit capabilities or the cgroup is not mounted. Limitation discarded.")
config.Resources.MemoryReservation = 0
}
- if config.Resources.MemoryReservation > 0 && config.Resources.MemoryReservation < linuxMinMemory {
- return warnings, fmt.Errorf("minimum memory reservation allowed is 4MB")
- }
if config.Resources.Memory > 0 && config.Resources.MemoryReservation > 0 && config.Resources.Memory < config.Resources.MemoryReservation {
return warnings, fmt.Errorf("minimum memory limit cannot be less than memory reservation limit, see usage")
}
@@ -130,9 +119,6 @@ func verifyContainerResources(config *cc.CreateConfig, update bool) ([]string, e
warnings = addWarning(warnings, "Your kernel does not support kernel memory limit capabilities or the cgroup is not mounted. Limitation discarded.")
config.Resources.KernelMemory = 0
}
- if config.Resources.KernelMemory > 0 && config.Resources.KernelMemory < linuxMinMemory {
- return warnings, fmt.Errorf("minimum kernel memory limit allowed is 4MB")
- }
if config.Resources.DisableOomKiller && !sysInfo.OomKillDisable {
// only produce warnings if the setting wasn't to *disable* the OOM Kill; no point
// warning the caller if they already wanted the feature to be off