summaryrefslogtreecommitdiff
path: root/libpod/boltdb_state.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-05-16 12:45:09 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-05-17 23:10:12 +0000
commit7e1ea9d26dff92c346bb11640fdab523d513e867 (patch)
tree28fca87c36fa1ddf5c357c61e2677626ed27835a /libpod/boltdb_state.go
parent018d2c6b1d23acf7fe67e809498bc354eaf6becf (diff)
downloadpodman-7e1ea9d26dff92c346bb11640fdab523d513e867.tar.gz
podman-7e1ea9d26dff92c346bb11640fdab523d513e867.tar.bz2
podman-7e1ea9d26dff92c346bb11640fdab523d513e867.zip
Add per-pod CGroups
Pods can now create their own (cgroupfs) cgroups which containers in them can (optionally) use. This presently only works with CGroupFS, systemd cgroups are still WIP Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #784 Approved by: rhatdan
Diffstat (limited to 'libpod/boltdb_state.go')
-rw-r--r--libpod/boltdb_state.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/libpod/boltdb_state.go b/libpod/boltdb_state.go
index 77b2fe5b7..805ff90fd 100644
--- a/libpod/boltdb_state.go
+++ b/libpod/boltdb_state.go
@@ -107,6 +107,11 @@ func (s *BoltState) Refresh() error {
return err
}
+ podsBucket, err := getPodBucket(tx)
+ if err != nil {
+ return err
+ }
+
// Iterate through all IDs. Check if they are containers.
// If they are, unmarshal their state, and then clear
// PID, mountpoint, and state for all of them
@@ -115,6 +120,38 @@ func (s *BoltState) Refresh() error {
err = idBucket.ForEach(func(id, name []byte) error {
ctrBkt := ctrsBucket.Bucket(id)
if ctrBkt == nil {
+ // It's a pod
+ podBkt := podsBucket.Bucket(id)
+ if podBkt == nil {
+ // This is neither a pod nor a container
+ // Error out on the dangling ID
+ return errors.Wrapf(ErrInternal, "id %s is not a pod or a container", string(id))
+ }
+
+ // Get the state
+ stateBytes := podBkt.Get(stateKey)
+ if stateBytes == nil {
+ return errors.Wrapf(ErrInternal, "pod %s missing state key", string(id))
+ }
+
+ state := new(podState)
+
+ if err := json.Unmarshal(stateBytes, state); err != nil {
+ return errors.Wrapf(err, "error unmarshalling state for pod %s", string(id))
+ }
+
+ // Clear the CGroup path
+ state.CgroupPath = ""
+
+ newStateBytes, err := json.Marshal(state)
+ if err != nil {
+ return errors.Wrapf(err, "error marshalling modified state for pod %s", string(id))
+ }
+
+ if err := podBkt.Put(stateKey, newStateBytes); err != nil {
+ return errors.Wrapf(err, "error updating state for pod %s in DB", string(id))
+ }
+
// It's not a container, nothing to do
return nil
}