diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-05-14 19:30:11 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-05-17 23:10:12 +0000 |
commit | 018d2c6b1d23acf7fe67e809498bc354eaf6becf (patch) | |
tree | 7e4a605898905c0e0b259717d642ecbabf2516d3 /libpod/boltdb_state_internal.go | |
parent | c45d4c6d5ce83a89f4c536e529c2a6e7a770837e (diff) | |
download | podman-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/boltdb_state_internal.go')
-rw-r--r-- | libpod/boltdb_state_internal.go | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/libpod/boltdb_state_internal.go b/libpod/boltdb_state_internal.go index 25dd216a3..29ed42f1e 100644 --- a/libpod/boltdb_state_internal.go +++ b/libpod/boltdb_state_internal.go @@ -256,13 +256,22 @@ func (s *BoltState) getPodFromDB(id []byte, pod *Pod, podBkt *bolt.Bucket) error return errors.Wrapf(ErrNoSuchPod, "pod with ID %s not found", string(id)) } - podBytes := podDB.Get(configKey) - if podBytes == nil { + podConfigBytes := podDB.Get(configKey) + if podConfigBytes == nil { return errors.Wrapf(ErrInternal, "pod %s is missing configuration key in DB", string(id)) } - if err := json.Unmarshal(podBytes, pod.config); err != nil { - return errors.Wrapf(err, "error unmarshalling pod %s from DB", string(id)) + if err := json.Unmarshal(podConfigBytes, pod.config); err != nil { + return errors.Wrapf(err, "error unmarshalling pod %s config from DB", string(id)) + } + + podStateBytes := podDB.Get(stateKey) + if podStateBytes == nil { + return errors.Wrapf(ErrInternal, "pod %s is missing state key in DB", string(id)) + } + + if err := json.Unmarshal(podStateBytes, pod.state); err != nil { + return errors.Wrapf(err, "error unmarshalling pod %s state from DB", string(id)) } // Get the lock |