summaryrefslogtreecommitdiff
path: root/libpod/runtime_pod.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-05-14 19:30:11 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-05-17 23:10:12 +0000
commit018d2c6b1d23acf7fe67e809498bc354eaf6becf (patch)
tree7e4a605898905c0e0b259717d642ecbabf2516d3 /libpod/runtime_pod.go
parentc45d4c6d5ce83a89f4c536e529c2a6e7a770837e (diff)
downloadpodman-018d2c6b1d23acf7fe67e809498bc354eaf6becf.tar.gz
podman-018d2c6b1d23acf7fe67e809498bc354eaf6becf.tar.bz2
podman-018d2c6b1d23acf7fe67e809498bc354eaf6becf.zip
Add pod state
Add a mutable state to pods, and database backend sutable for modifying and updating said state. Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #784 Approved by: rhatdan
Diffstat (limited to 'libpod/runtime_pod.go')
-rw-r--r--libpod/runtime_pod.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/libpod/runtime_pod.go b/libpod/runtime_pod.go
index 257b980a2..4ca8da9ee 100644
--- a/libpod/runtime_pod.go
+++ b/libpod/runtime_pod.go
@@ -1,6 +1,9 @@
package libpod
import (
+ "path"
+ "strings"
+
"github.com/pkg/errors"
)
@@ -45,6 +48,24 @@ func (r *Runtime) NewPod(options ...PodCreateOption) (*Pod, error) {
pod.valid = true
+ // Check CGroup parent sanity, and set it if it was not set
+ switch r.config.CgroupManager {
+ case CgroupfsCgroupsManager:
+ if pod.config.CgroupParent == "" {
+ pod.config.CgroupParent = CgroupfsDefaultCgroupParent
+ } else if strings.HasSuffix(path.Base(pod.config.CgroupParent), ".slice") {
+ return nil, errors.Wrapf(ErrInvalidArg, "systemd slice received as cgroup parent when using cgroupfs")
+ }
+ case SystemdCgroupsManager:
+ if pod.config.CgroupParent == "" {
+ pod.config.CgroupParent = SystemdDefaultCgroupParent
+ } else if len(pod.config.CgroupParent) < 6 || !strings.HasSuffix(path.Base(pod.config.CgroupParent), ".slice") {
+ return nil, errors.Wrapf(ErrInvalidArg, "did not receive systemd slice as cgroup parent when using systemd to manage cgroups")
+ }
+ default:
+ return nil, errors.Wrapf(ErrInvalidArg, "unsupported CGroup manager: %s - cannot validate cgroup parent", r.config.CgroupManager)
+ }
+
if err := r.state.AddPod(pod); err != nil {
return nil, errors.Wrapf(err, "error adding pod to state")
}