libnet: Return a 403 when overlay network isn't allowed
With this change, the API will now return a 403 instead of a 500 when trying to create an overlay network on a non-manager node. Signed-off-by: Albin Kerouanton <albinker@gmail.com>
This commit is contained in:
parent
21dcbada2d
commit
d29240d9eb
2 changed files with 4 additions and 2 deletions
|
@ -9900,7 +9900,9 @@ paths:
|
|||
Id: "22be93d5babb089c5aab8dbc369042fad48ff791584ca2da2100db837a1c7c30"
|
||||
Warning: ""
|
||||
403:
|
||||
description: "operation not supported for pre-defined networks"
|
||||
description: |
|
||||
Forbidden operation. This happens when trying to create a network named after a pre-defined network,
|
||||
or when trying to create an overlay network on a daemon which is not part of a Swarm cluster.
|
||||
schema:
|
||||
$ref: "#/definitions/ErrorResponse"
|
||||
404:
|
||||
|
|
|
@ -300,7 +300,7 @@ func (daemon *Daemon) createNetwork(cfg *config.Config, create types.NetworkCrea
|
|||
}
|
||||
|
||||
if driver == "overlay" && !daemon.cluster.IsManager() && !agent {
|
||||
return nil, errors.New(`This node is not a swarm manager. Use "docker swarm init" or "docker swarm join" to connect this node to swarm and try again.`)
|
||||
return nil, errdefs.Forbidden(errors.New(`This node is not a swarm manager. Use "docker swarm init" or "docker swarm join" to connect this node to swarm and try again.`))
|
||||
}
|
||||
|
||||
var warning string
|
||||
|
|
Loading…
Add table
Reference in a new issue