Skip to content

Service create API returns 5xx status instead of 4xx #38140

@thaJeztah

Description

@thaJeztah

(as reported by @waseemshahwan in #31909 (comment))

Looks like a regression was introduced somewhere between Docker 17.07 and 17.09.1, causing the status code for a "conflict" to change from a 409 to a 500;

To reproduce; run a "service create" request twice (second time should return a "conflict";

curl -v \
  --unix-socket /var/run/docker.sock \
  -X POST \
  "http://localhost/v1.30/services/create" \
  -H "Content-Type: application/json" \
  -d '{"EndpointSpec":{"Mode":"vip"},"Labels":{},"Mode":{"Replicated":{}},"Name":"testing","TaskTemplate":{"ContainerSpec":{"DNSConfig":{},"Image":"nginx:alpine@sha256:ae5da813f8ad7fa785d7668f0b018ecc8c3a87331527a61d83b3b5e816a0f03c","Init":false},"ForceUpdate":0,"Placement":{"Platforms":[{"Architecture":"amd64","OS":"linux"},{"OS":"linux"},{"Architecture":"arm64","OS":"linux"},{"Architecture":"386","OS":"linux"},{"Architecture":"ppc64le","OS":"linux"},{"Architecture":"s390x","OS":"linux"}]},"Resources":{"Limits":{},"Reservations":{}}}}'

On Docker 17.07.0-ce

> POST /v1.30/services/create HTTP/1.1
> Host: localhost
> User-Agent: curl/7.61.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 536
> 
* upload completely sent off: 536 out of 536 bytes
< HTTP/1.1 409 Conflict
< Api-Version: 1.31
< Content-Type: application/json
< Docker-Experimental: false
< Ostype: linux
< Server: Docker/17.07.0-ce (linux)
< Date: Mon, 05 Nov 2018 16:10:58 GMT
< Content-Length: 86
< 
{"message":"rpc error: code = Unknown desc = name conflicts with an existing object"}

On Docker 17.09.1-ce

> POST /v1.30/services/create HTTP/1.1
> Host: localhost
> User-Agent: curl/7.61.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 536
> 
* upload completely sent off: 536 out of 536 bytes
< HTTP/1.1 500 Internal Server Error
< Api-Version: 1.32
< Content-Type: application/json
< Docker-Experimental: false
< Ostype: linux
< Server: Docker/17.09.1-ce (linux)
< Date: Mon, 05 Nov 2018 16:11:59 GMT
< Content-Length: 86
< 
{"message":"rpc error: code = Unknown desc = name conflicts with an existing object"}

On 18.06.1-ce (still reproduces)

*   Trying /var/run/docker.sock...
* Connected to localhost (/var/run/docker.sock) port 80 (#0)
> POST /v1.30/services/create HTTP/1.1
> Host: localhost
> User-Agent: curl/7.61.1
> Accept: */*
> Content-Type: application/json
> Content-Length: 536
> 
* upload completely sent off: 536 out of 536 bytes
< HTTP/1.1 500 Internal Server Error
< Api-Version: 1.38
< Content-Type: application/json
< Docker-Experimental: false
< Ostype: linux
< Server: Docker/18.06.1-ce (linux)
< Date: Mon, 05 Nov 2018 10:31:29 GMT
< Content-Length: 86
< 
{"message":"rpc error: code = Unknown desc = name conflicts with an existing object"}
* Connection #0 to host localhost left intact

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions