diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-07-30 09:42:35 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-07-31 14:19:50 +0000 |
commit | 1db70cce344724e091635bc8c6fa6c207450df68 (patch) | |
tree | ed48df83141568bb949a8bdd5611cd20b3fa42c2 /libpod/boltdb_state_internal.go | |
parent | cfcd92847684fc65949350b7cdc4769ad1099d46 (diff) | |
download | podman-1db70cce344724e091635bc8c6fa6c207450df68.tar.gz podman-1db70cce344724e091635bc8c6fa6c207450df68.tar.bz2 podman-1db70cce344724e091635bc8c6fa6c207450df68.zip |
Do not fetch pod and ctr State on retrieval in Bolt
It's not necessary to fill in state immediately, as we'll be
overwriting it on any API call accessing it thanks to
syncContainer(). It is also causing races when we fetch it
without holding the container lock (which syncContainer() does).
As such, just don't retrieve the state on initial pull from the
database with Bolt.
Also, refactor some Linux-specific netns handling functions out
of container_internal_linux.go into boltdb_linux.go.
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Closes: #1186
Approved by: rhatdan
Diffstat (limited to 'libpod/boltdb_state_internal.go')
-rw-r--r-- | libpod/boltdb_state_internal.go | 26 |
1 files changed, 1 insertions, 25 deletions
diff --git a/libpod/boltdb_state_internal.go b/libpod/boltdb_state_internal.go index 01ebae78f..cc7d106cc 100644 --- a/libpod/boltdb_state_internal.go +++ b/libpod/boltdb_state_internal.go @@ -256,25 +256,10 @@ func (s *BoltState) getContainerFromDB(id []byte, ctr *Container, ctrsBkt *bolt. return errors.Wrapf(ErrInternal, "container %s missing config key in DB", string(id)) } - stateBytes := ctrBkt.Get(stateKey) - if stateBytes == nil { - return errors.Wrapf(ErrInternal, "container %s missing state key in DB", string(id)) - } - - netNSBytes := ctrBkt.Get(netNSKey) - if err := json.Unmarshal(configBytes, ctr.config); err != nil { return errors.Wrapf(err, "error unmarshalling container %s config", string(id)) } - if err := json.Unmarshal(stateBytes, ctr.state); err != nil { - return errors.Wrapf(err, "error unmarshalling container %s state", string(id)) - } - - if !parseNetNSBoltData(ctr, netNSBytes) { - valid = false - } - // Get the lock lockPath := filepath.Join(s.lockDir, string(id)) lock, err := storage.GetLockfile(lockPath) @@ -311,15 +296,6 @@ func (s *BoltState) getPodFromDB(id []byte, pod *Pod, podBkt *bolt.Bucket) error 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 lockPath := filepath.Join(s.lockDir, string(id)) lock, err := storage.GetLockfile(lockPath) @@ -352,7 +328,7 @@ func (s *BoltState) addContainer(ctr *Container, pod *Pod) error { if err != nil { return errors.Wrapf(err, "error marshalling container %s state to JSON", ctr.ID()) } - netNSPath := ctr.setNamespaceStatePath() + netNSPath := getNetNSPath(ctr) dependsCtrs := ctr.Dependencies() ctrID := []byte(ctr.ID()) |