summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2019-10-28 19:13:12 +0100
committerGitHub <noreply@github.com>2019-10-28 19:13:12 +0100
commit49bd51e12f3aa8f2f711832d1dc4134861ee29c8 (patch)
tree3e352fccf732170f77e22ab00b9733961bf0f912
parent94864adb2888c6648bd061004e81dd20f8a30280 (diff)
parent84eea2b2c09385078d7b147954ec9be3da608214 (diff)
downloadpodman-49bd51e12f3aa8f2f711832d1dc4134861ee29c8.tar.gz
podman-49bd51e12f3aa8f2f711832d1dc4134861ee29c8.tar.bz2
podman-49bd51e12f3aa8f2f711832d1dc4134861ee29c8.zip
Merge pull request #4331 from mheon/sane_rename_error
Return a better error for volume name conflicts
-rw-r--r--libpod/runtime_volume_linux.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/libpod/runtime_volume_linux.go b/libpod/runtime_volume_linux.go
index ba4fff4be..5b05acea4 100644
--- a/libpod/runtime_volume_linux.go
+++ b/libpod/runtime_volume_linux.go
@@ -48,6 +48,15 @@ func (r *Runtime) newVolume(ctx context.Context, options ...VolumeCreateOption)
}
volume.config.CreatedTime = time.Now()
+ // Check if volume with given name exists.
+ exists, err := r.state.HasVolume(volume.config.Name)
+ if err != nil {
+ return nil, errors.Wrapf(err, "error checking if volume with name %s exists", volume.config.Name)
+ }
+ if exists {
+ return nil, errors.Wrapf(define.ErrVolumeExists, "volume with name %s already exists", volume.config.Name)
+ }
+
if volume.config.Driver == define.VolumeDriverLocal {
logrus.Debugf("Validating options for local driver")
// Validate options