Skip to content

Secrets API: Name conflict returns 500, should be 409 #31909

@johnflavin

Description

@johnflavin

Description

When I create a secret, then try to create a new secret with the same name, the HTTP error code I get back is wrong.

Steps to reproduce the issue:

  1. Create a secret (either through the command line or the REST API).
$ echo "secrets" | docker secret create my-secret -
  1. Attempt to create another secret with the same name (this time using the REST API, so you can see the HTTP status you get back.)
$ curl -i --unix-socket /var/run/docker.sock -X POST -H 'content-type: application/json' -d '{"Name": "my-secret", "Data": "c2VjcmV0cwo="}' http://localhost/secrets/create

Describe the results you received:
HTTP 500

HTTP/1.1 500 Internal Server Error
Api-Version: 1.26
Content-Length: 73
Content-Type: application/json
Date: Fri, 17 Mar 2017 03:04:56 GMT
Docker-Experimental: true
Server: Docker/17.03.0-ce (linux)

{"message":"rpc error: code = 6 desc = secret my-secret already exists"}

Describe the results you expected:
HTTP 409 conflict, as stated in the swagger spec.

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

Client:
 Version:      17.03.0-ce
 API version:  1.26
 Go version:   go1.7.5
 Git commit:   60ccb22
 Built:        Thu Feb 23 10:40:59 2017
 OS/Arch:      darwin/amd64

Server:
 Version:      17.03.0-ce
 API version:  1.26 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   3a232c8
 Built:        Tue Feb 28 07:52:04 2017
 OS/Arch:      linux/amd64
 Experimental: true

Output of docker info:

Containers: 2
 Running: 0
 Paused: 0
 Stopped: 2
Images: 20
Server Version: 17.03.0-ce
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 34
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
Swarm: active
 NodeID: 2n2g46cvu27nk0yuoowhe1t8b
 Is Manager: true
 ClusterID: 3j26e6low77hibavv55u87hvp
 Managers: 1
 Nodes: 1
 Orchestration:
  Task History Retention Limit: 5
 Raft:
  Snapshot Interval: 10000
  Number of Old Snapshots to Retain: 0
  Heartbeat Tick: 1
  Election Tick: 3
 Dispatcher:
  Heartbeat Period: 5 seconds
 CA Configuration:
  Expiry Duration: 3 months
 Node Address: 192.168.65.2
 Manager Addresses:
  192.168.65.2:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 977c511eda0925a723debdc94d09459af49d082a
runc version: a01dafd48bc1c7cc12bdb01206f9fea7dd6feb70
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.12-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 1.952 GiB
Name: moby
ID: 3NXV:6OUU:O7VQ:BPBV:XDC2:ZPMT:IRSG:VJ3I:SL2H:ZWC2:ECT6:7X4R
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 33
 Goroutines: 131
 System Time: 2017-03-17T03:11:47.838534917Z
 EventsListeners: 1
No Proxy: *.local, 169.254/16
Username: xnat
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

Additional environment details (AWS, VirtualBox, physical, etc.):
I have seen this on Docker for Mac and Ubuntu 14.04, the latter using docker versions 1.13.1 and 17.03.0-ce.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions