summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-09-28 20:26:09 +0000
committerGitHub <noreply@github.com>2020-09-28 20:26:09 +0000
commit6b803a66fa1cd8777f54ed4b4da791f0e7657a60 (patch)
treed7896d6fc92f0887c600babf1046ef14d0ea89cd
parentb0e70a6411d70d7ee7f1e9d6abedc2524b903609 (diff)
parentbe88d45f5a0b23ad26859ec85e2825e818882365 (diff)
downloadpodman-6b803a66fa1cd8777f54ed4b4da791f0e7657a60.tar.gz
podman-6b803a66fa1cd8777f54ed4b4da791f0e7657a60.tar.bz2
podman-6b803a66fa1cd8777f54ed4b4da791f0e7657a60.zip
Merge pull request #7804 from baude/issue7740
fix for compatibility volume creation
-rw-r--r--pkg/api/handlers/compat/volumes.go23
-rw-r--r--pkg/api/server/register_volumes.go4
2 files changed, 26 insertions, 1 deletions
diff --git a/pkg/api/handlers/compat/volumes.go b/pkg/api/handlers/compat/volumes.go
index 976c52acb..a45509fdb 100644
--- a/pkg/api/handlers/compat/volumes.go
+++ b/pkg/api/handlers/compat/volumes.go
@@ -93,6 +93,29 @@ func CreateVolume(w http.ResponseWriter, r *http.Request) {
return
}
+ // See if the volume exists already
+ existingVolume, err := runtime.GetVolume(input.Name)
+ if err != nil && errors.Cause(err) != define.ErrNoSuchVolume {
+ utils.InternalServerError(w, err)
+ return
+ }
+
+ // if using the compat layer and the volume already exists, we
+ // must return a 201 with the same information as create
+ if existingVolume != nil && !utils.IsLibpodRequest(r) {
+ response := docker_api_types.Volume{
+ CreatedAt: existingVolume.CreatedTime().Format(time.RFC3339),
+ Driver: existingVolume.Driver(),
+ Labels: existingVolume.Labels(),
+ Mountpoint: existingVolume.MountPoint(),
+ Name: existingVolume.Name(),
+ Options: existingVolume.Options(),
+ Scope: existingVolume.Scope(),
+ }
+ utils.WriteResponse(w, http.StatusCreated, response)
+ return
+ }
+
if len(input.Name) > 0 {
volumeOptions = append(volumeOptions, libpod.WithVolumeName(input.Name))
}
diff --git a/pkg/api/server/register_volumes.go b/pkg/api/server/register_volumes.go
index 22488b158..aa0f67604 100644
--- a/pkg/api/server/register_volumes.go
+++ b/pkg/api/server/register_volumes.go
@@ -154,7 +154,9 @@ func (s *APIServer) registerVolumeHandlers(r *mux.Router) error {
// parameters:
// - in: body
// name: create
- // description: attributes for creating a container
+ // description: |
+ // attributes for creating a container.
+ // Note: If a volume by the same name exists, a 201 response with that volume's information will be generated.
// schema:
// $ref: "#/definitions/DockerVolumeCreate"
// produces: