diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-08-28 11:25:12 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-28 11:25:12 -0700 |
commit | bdf9e568134c37f02f662080cfe32f7ca98710c9 (patch) | |
tree | c310ec1ca3d1cdb3db69c2972fa8e2322a4badbe /libpod/in_memory_state.go | |
parent | ced3ebb512e1b578184317e9ff6474f892d1c382 (diff) | |
parent | e563f4111600a6c5506e4953bf796783a097544f (diff) | |
download | podman-bdf9e568134c37f02f662080cfe32f7ca98710c9.tar.gz podman-bdf9e568134c37f02f662080cfe32f7ca98710c9.tar.bz2 podman-bdf9e568134c37f02f662080cfe32f7ca98710c9.zip |
Merge pull request #3893 from mheon/readd_volume_locks
Re-add volume locks
Diffstat (limited to 'libpod/in_memory_state.go')
-rw-r--r-- | libpod/in_memory_state.go | 20 |
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 == "" { |