summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-09-11 00:58:46 +0200
committerGitHub <noreply@github.com>2019-09-11 00:58:46 +0200
commit7ac6ed3b4b27621e7aa15da335e65ffa601fb83e (patch)
tree397083da135855ec39a94abd834fefc18079607a /pkg
parent997c4b56ed2121726e966afe9a102ed16ba78f93 (diff)
parentc2284962c798a11f3c956ee237f27cfd3b0fcb21 (diff)
downloadpodman-7ac6ed3b4b27621e7aa15da335e65ffa601fb83e.tar.gz
podman-7ac6ed3b4b27621e7aa15da335e65ffa601fb83e.tar.bz2
podman-7ac6ed3b4b27621e7aa15da335e65ffa601fb83e.zip
Merge pull request #3581 from mheon/no_cgroups
Support running containers without CGroups
Diffstat (limited to 'pkg')
-rw-r--r--pkg/spec/createconfig.go4
-rw-r--r--pkg/spec/spec.go12
2 files changed, 16 insertions, 0 deletions
diff --git a/pkg/spec/createconfig.go b/pkg/spec/createconfig.go
index 3f70e5935..c17172016 100644
--- a/pkg/spec/createconfig.go
+++ b/pkg/spec/createconfig.go
@@ -64,6 +64,7 @@ type CreateConfig struct {
CidFile string
ConmonPidFile string
Cgroupns string
+ Cgroups string
CgroupParent string // cgroup-parent
Command []string // Full command that will be used
UserCommand []string // User-entered command (or image CMD)
@@ -206,6 +207,9 @@ func (c *CreateConfig) getContainerCreateOptions(runtime *libpod.Runtime, pod *l
logrus.Debugf("adding container to pod %s", c.Pod)
options = append(options, runtime.WithPod(pod))
}
+ if c.Cgroups == "disabled" {
+ options = append(options, libpod.WithNoCgroups())
+ }
if len(c.PortBindings) > 0 {
portBindings, err = c.CreatePortBindings()
if err != nil {
diff --git a/pkg/spec/spec.go b/pkg/spec/spec.go
index 44bbda885..38f9c7306 100644
--- a/pkg/spec/spec.go
+++ b/pkg/spec/spec.go
@@ -396,6 +396,18 @@ func (config *CreateConfig) createConfigToOCISpec(runtime *libpod.Runtime, userM
}
}
+ switch config.Cgroups {
+ case "disabled":
+ if addedResources {
+ return nil, errors.New("cannot specify resource limits when cgroups are disabled is specified")
+ }
+ configSpec.Linux.Resources = &spec.LinuxResources{}
+ case "enabled", "":
+ // Do nothing
+ default:
+ return nil, errors.New("unrecognized option for cgroups; supported are 'default' and 'disabled'")
+ }
+
// Add annotations
if configSpec.Annotations == nil {
configSpec.Annotations = make(map[string]string)