Merge pull request #35022 from thaJeztah/fix-conflict-status-code
Fix conflicting container name producing 400 error instead of 409 Upstream-commit: f8806b18b4b92c5e1980f6e11c917fad201cd73c Component: engine
This commit is contained in:
@ -64,6 +64,17 @@ func errExecPaused(id string) error {
|
||||
return stateConflictError{cause}
|
||||
}
|
||||
|
||||
type nameConflictError struct {
|
||||
id string
|
||||
name string
|
||||
}
|
||||
|
||||
func (e nameConflictError) Error() string {
|
||||
return fmt.Sprintf("Conflict. The container name %q is already in use by container %q. You have to remove (or rename) that container to be able to reuse that name.", e.name, e.id)
|
||||
}
|
||||
|
||||
func (nameConflictError) Conflict() {}
|
||||
|
||||
type validationError struct {
|
||||
cause error
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ func (daemon *Daemon) reserveName(id, name string) (string, error) {
|
||||
logrus.Errorf("got unexpected error while looking up reserved name: %v", err)
|
||||
return "", err
|
||||
}
|
||||
return "", validationError{errors.Errorf("Conflict. The container name %q is already in use by container %q. You have to remove (or rename) that container to be able to reuse that name.", name, id)}
|
||||
return "", nameConflictError{id: id, name: name}
|
||||
}
|
||||
return "", errors.Wrapf(err, "error reserving name: %q", name)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user