From 89c44107996376baa2b123396a2b6c30484ad6c4 Mon Sep 17 00:00:00 2001 From: allencloud Date: Sun, 13 Nov 2016 12:39:02 +0800 Subject: [PATCH] judge manager before getting secret Signed-off-by: allencloud --- daemon/cluster/secrets.go | 7 +++++++ docs/reference/api/docker_remote_api_v1.25.md | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/daemon/cluster/secrets.go b/daemon/cluster/secrets.go index 27114152f4..2b9eb5da1d 100644 --- a/daemon/cluster/secrets.go +++ b/daemon/cluster/secrets.go @@ -9,6 +9,13 @@ import ( // GetSecret returns a secret from a managed swarm cluster func (c *Cluster) GetSecret(id string) (types.Secret, error) { + c.RLock() + defer c.RUnlock() + + if !c.isActiveManager() { + return types.Secret{}, c.errNoManager() + } + ctx, cancel := c.getRequestContext() defer cancel() diff --git a/docs/reference/api/docker_remote_api_v1.25.md b/docs/reference/api/docker_remote_api_v1.25.md index 6e0e153aab..287df88c85 100644 --- a/docs/reference/api/docker_remote_api_v1.25.md +++ b/docs/reference/api/docker_remote_api_v1.25.md @@ -6060,9 +6060,9 @@ Create a secret ### Inspect a secret -`GET /secrets/(secret id)` +`GET /secrets/(id)` -Get details on a secret +Get details on the secret `id` **Example request**: @@ -6088,6 +6088,7 @@ Get details on a secret - **200** – no error - **404** – unknown secret +- **406** – node is not part of a swarm - **500** – server error ### Remove a secret