diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-08-04 15:46:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-04 15:46:13 +0200 |
commit | d4cf3c589d09dd395a3b63e82f5a5c198535cb46 (patch) | |
tree | 1b1f9229c8dcf8f95294bcd85a70da3492adc576 /libpod/boltdb_state.go | |
parent | 93d63208bbc6b75c6831302ac2c3c7b05cc743ce (diff) | |
parent | 97b2b079532ba983820e259b96ede027b846888b (diff) | |
download | podman-d4cf3c589d09dd395a3b63e82f5a5c198535cb46.tar.gz podman-d4cf3c589d09dd395a3b63e82f5a5c198535cb46.tar.bz2 podman-d4cf3c589d09dd395a3b63e82f5a5c198535cb46.zip |
Merge pull request #7207 from Luap99/pod/ctr-exists-error
Improve error message when creating a pod/ctr with the same name
Diffstat (limited to 'libpod/boltdb_state.go')
-rw-r--r-- | libpod/boltdb_state.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libpod/boltdb_state.go b/libpod/boltdb_state.go index e98a6e907..2575f0e86 100644 --- a/libpod/boltdb_state.go +++ b/libpod/boltdb_state.go @@ -2347,11 +2347,19 @@ func (s *BoltState) AddPod(pod *Pod) error { // Check if we already have something with the given ID and name idExist := idsBkt.Get(podID) if idExist != nil { - return errors.Wrapf(define.ErrPodExists, "ID %s is in use", pod.ID()) + err = define.ErrPodExists + if allPodsBkt.Get(idExist) == nil { + err = define.ErrCtrExists + } + return errors.Wrapf(err, "ID \"%s\" is in use", pod.ID()) } nameExist := namesBkt.Get(podName) if nameExist != nil { - return errors.Wrapf(define.ErrPodExists, "name %s is in use", pod.Name()) + err = define.ErrPodExists + if allPodsBkt.Get(nameExist) == nil { + err = define.ErrCtrExists + } + return errors.Wrapf(err, "name \"%s\" is in use", pod.Name()) } // We are good to add the pod |