summaryrefslogtreecommitdiff
path: root/cmd/podman/common/specgen.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman/common/specgen.go')
-rw-r--r--cmd/podman/common/specgen.go27
1 files changed, 13 insertions, 14 deletions
diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go
index 975c76fd9..2fafbfac1 100644
--- a/cmd/podman/common/specgen.go
+++ b/cmd/podman/common/specgen.go
@@ -8,14 +8,14 @@ import (
"time"
"github.com/containers/image/v5/manifest"
- "github.com/containers/podman/v2/cmd/podman/parse"
- "github.com/containers/podman/v2/libpod/define"
- ann "github.com/containers/podman/v2/pkg/annotations"
- envLib "github.com/containers/podman/v2/pkg/env"
- ns "github.com/containers/podman/v2/pkg/namespaces"
- "github.com/containers/podman/v2/pkg/specgen"
- systemdGen "github.com/containers/podman/v2/pkg/systemd/generate"
- "github.com/containers/podman/v2/pkg/util"
+ "github.com/containers/podman/v3/cmd/podman/parse"
+ "github.com/containers/podman/v3/libpod/define"
+ ann "github.com/containers/podman/v3/pkg/annotations"
+ envLib "github.com/containers/podman/v3/pkg/env"
+ ns "github.com/containers/podman/v3/pkg/namespaces"
+ "github.com/containers/podman/v3/pkg/specgen"
+ systemdGen "github.com/containers/podman/v3/pkg/systemd/generate"
+ "github.com/containers/podman/v3/pkg/util"
"github.com/docker/go-units"
"github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
@@ -148,17 +148,16 @@ func getMemoryLimits(s *specgen.SpecGenerator, c *ContainerCLIOpts) (*specs.Linu
}
if m := c.MemorySwap; len(m) > 0 {
var ms int64
- if m == "-1" {
- ms = int64(-1)
- s.ResourceLimits.Memory.Swap = &ms
- } else {
+ // only set memory swap if it was set
+ // -1 indicates unlimited
+ if m != "-1" {
ms, err = units.RAMInBytes(m)
+ memory.Swap = &ms
if err != nil {
return nil, errors.Wrapf(err, "invalid value for memory")
}
+ hasLimits = true
}
- memory.Swap = &ms
- hasLimits = true
}
if m := c.KernelMemory; len(m) > 0 {
mk, err := units.RAMInBytes(m)