summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-08-18 19:45:10 -0400
committerGitHub <noreply@github.com>2021-08-18 19:45:10 -0400
commit2f9bd63c9d2c0e18db7d35e0a1ea08624d21c3a2 (patch)
tree796dc94a437518295a6cc764857873b2248b9c92
parent92fcf9153345a701f5351b89e349c16b04ed4955 (diff)
parent592fae4225619755bdcc9f26416eab1c450f9811 (diff)
downloadpodman-2f9bd63c9d2c0e18db7d35e0a1ea08624d21c3a2.tar.gz
podman-2f9bd63c9d2c0e18db7d35e0a1ea08624d21c3a2.tar.bz2
podman-2f9bd63c9d2c0e18db7d35e0a1ea08624d21c3a2.zip
Merge pull request #11267 from mheon/fix_11214
Volumes: Only remove from DB if plugin removal succeeds
-rw-r--r--libpod/runtime_volume_linux.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/libpod/runtime_volume_linux.go b/libpod/runtime_volume_linux.go
index 40df98d7c..d1ea7d4fd 100644
--- a/libpod/runtime_volume_linux.go
+++ b/libpod/runtime_volume_linux.go
@@ -255,11 +255,6 @@ func (r *Runtime) removeVolume(ctx context.Context, v *Volume, force bool) error
// Set volume as invalid so it can no longer be used
v.valid = false
- // Remove the volume from the state
- if err := r.state.RemoveVolume(v); err != nil {
- return errors.Wrapf(err, "error removing volume %s", v.Name())
- }
-
var removalErr error
// If we use a volume plugin, we need to remove from the plugin.
@@ -287,11 +282,19 @@ func (r *Runtime) removeVolume(ctx context.Context, v *Volume, force bool) error
req := new(pluginapi.RemoveRequest)
req.Name = v.Name()
if err := v.plugin.RemoveVolume(req); err != nil {
- removalErr = errors.Wrapf(err, "volume %s could not be removed from plugin %s, but it has been removed from Podman", v.Name(), v.Driver())
+ return errors.Wrapf(err, "volume %s could not be removed from plugin %s", v.Name(), v.Driver())
}
}
}
+ // Remove the volume from the state
+ if err := r.state.RemoveVolume(v); err != nil {
+ if removalErr != nil {
+ logrus.Errorf("Error removing volume %s from plugin %s: %v", v.Name(), v.Driver(), removalErr)
+ }
+ return errors.Wrapf(err, "error removing volume %s", v.Name())
+ }
+
// Free the volume's lock
if err := v.lock.Free(); err != nil {
if removalErr == nil {