From 363a82e6682f6b7afc6f9159c778e18009cd7c74 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Thu, 8 Feb 2018 13:55:02 -0500 Subject: Add pod buckets Signed-off-by: Matthew Heon Closes: #184 Approved by: baude --- libpod/boltdb_state.go | 8 ++++++++ libpod/boltdb_state_internal.go | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) (limited to 'libpod') diff --git a/libpod/boltdb_state.go b/libpod/boltdb_state.go index 5502ec1b4..3584c9a9d 100644 --- a/libpod/boltdb_state.go +++ b/libpod/boltdb_state.go @@ -69,6 +69,14 @@ func NewBoltState(path, lockDir string, runtime *Runtime) (State, error) { if err != nil { return errors.Wrapf(err, "error creating container-depends bucket") } + _, err = tx.CreateBucketIfNotExists(podBkt) + if err != nil { + return errors.Wrapf(err, "error creating pod bucket") + } + _, err = tx.CreateBucketIfNotExists(podContainersBkt) + if err != nil { + return errors.Wrapf(err, "error creating pod-containers bucket") + } return nil }) if err != nil { diff --git a/libpod/boltdb_state_internal.go b/libpod/boltdb_state_internal.go index 8b4e8e28c..c8aa4adbf 100644 --- a/libpod/boltdb_state_internal.go +++ b/libpod/boltdb_state_internal.go @@ -17,6 +17,8 @@ const ( netNSName = "net-ns" runtimeConfigName = "runtime-config" ctrDependsName = "container-depends" + podName = "pod" + podContainersName = "pod-containers" ) var ( @@ -27,6 +29,8 @@ var ( netNSBkt = []byte(netNSName) runtimeConfigBkt = []byte(runtimeConfigName) ctrDependsBkt = []byte(ctrDependsName) + podBkt = []byte(podName) + podContainersBkt = []byte(podContainersName) ) // Check if the configuration of the database is compatible with the @@ -158,6 +162,22 @@ func getCtrDependsBucket(tx *bolt.Tx) (*bolt.Bucket, error) { return bkt, nil } +func getPodBucket(tx *bolt.Tx) (*bolt.Bucket, error) { + bkt := tx.Bucket(podBkt) + if bkt == nil { + return nil, errors.Wrapf(ErrDBBadConfig, "pods bucket not found in DB") + } + return bkt, nil +} + +func getPodContainersBucket(tx *bolt.Tx) (*bolt.Bucket, error) { + bkt := tx.Bucket(podContainersBkt) + if bkt == nil { + return nil, errors.Wrapf(ErrDBBadConfig, "pod containers bucket not found in DB") + } + return bkt, nil +} + func (s *BoltState) getContainerFromDB(id []byte, ctr *Container, config, state, netNS *bolt.Bucket) error { configBytes := config.Get(id) if configBytes == nil { -- cgit v1.2.3-54-g00ecf