aboutsummaryrefslogtreecommitdiff
path: root/libpod/boltdb_state_internal.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-08-30 16:09:17 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-09-05 12:29:36 -0400
commit5a8a71ed817a4fa50fd9444846a50b76f25228d1 (patch)
treedee3a3bc42d410ff184acfa38d49ac1e5ad5bbed /libpod/boltdb_state_internal.go
parentc8193633cd82228b01e789becead410c2a940227 (diff)
downloadpodman-5a8a71ed817a4fa50fd9444846a50b76f25228d1.tar.gz
podman-5a8a71ed817a4fa50fd9444846a50b76f25228d1.tar.bz2
podman-5a8a71ed817a4fa50fd9444846a50b76f25228d1.zip
Add volume state
We need to be able to track the number of times a volume has been mounted for tmpfs/nfs/etc volumes. As such, we need a mutable state for volumes. Add one, with the expected update/save methods in both states. There is backwards compat here, in that older volumes without a state will still be accepted. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod/boltdb_state_internal.go')
-rw-r--r--libpod/boltdb_state_internal.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/libpod/boltdb_state_internal.go b/libpod/boltdb_state_internal.go
index 6e4179835..8dc3d1309 100644
--- a/libpod/boltdb_state_internal.go
+++ b/libpod/boltdb_state_internal.go
@@ -449,6 +449,14 @@ func (s *BoltState) getVolumeFromDB(name []byte, volume *Volume, volBkt *bolt.Bu
return errors.Wrapf(err, "error unmarshalling volume %s config from DB", string(name))
}
+ // Volume state is allowed to be nil for legacy compatability
+ volStateBytes := volDB.Get(stateKey)
+ if volStateBytes != nil {
+ if err := json.Unmarshal(volStateBytes, volume.state); err != nil {
+ return errors.Wrapf(err, "error unmarshalling volume %s state from DB", string(name))
+ }
+ }
+
// Get the lock
lock, err := s.runtime.lockManager.RetrieveLock(volume.config.LockID)
if err != nil {