summaryrefslogtreecommitdiff
path: root/libpod/in_memory_state.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-08-27 13:45:11 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-08-28 11:35:00 -0400
commite563f4111600a6c5506e4953bf796783a097544f (patch)
tree54cae975be3d0de2805d15d3305d74ef798ce799 /libpod/in_memory_state.go
parentf221c6101934fccbd6705f3b387aadc9ae710f66 (diff)
downloadpodman-e563f4111600a6c5506e4953bf796783a097544f.tar.gz
podman-e563f4111600a6c5506e4953bf796783a097544f.tar.bz2
podman-e563f4111600a6c5506e4953bf796783a097544f.zip
Re-add locks to volumes.
This will require a 'podman system renumber' after being applied to get lock numbers for existing volumes. Add the DB backend code for rewriting volume configs and use it for updating lock numbers as part of 'system renumber'. Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod/in_memory_state.go')
-rw-r--r--libpod/in_memory_state.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/libpod/in_memory_state.go b/libpod/in_memory_state.go
index 7c4abd25d..a9b735327 100644
--- a/libpod/in_memory_state.go
+++ b/libpod/in_memory_state.go
@@ -425,6 +425,26 @@ func (s *InMemoryState) RewritePodConfig(pod *Pod, newCfg *PodConfig) error {
return nil
}
+// RewriteVolumeConfig rewrites a volume's configuration.
+// This function is DANGEROUS, even with in-memory state.
+// Please read the full comment in state.go before using it.
+func (s *InMemoryState) RewriteVolumeConfig(volume *Volume, newCfg *VolumeConfig) error {
+ if !volume.valid {
+ return define.ErrVolumeRemoved
+ }
+
+ // If the volume does not exist, return error
+ stateVol, ok := s.volumes[volume.Name()]
+ if !ok {
+ volume.valid = false
+ return errors.Wrapf(define.ErrNoSuchVolume, "volume with name %q not found in state", volume.Name())
+ }
+
+ stateVol.config = newCfg
+
+ return nil
+}
+
// Volume retrieves a volume from its full name
func (s *InMemoryState) Volume(name string) (*Volume, error) {
if name == "" {