From cd587419d017894ae1c3cd365feffa804cbe2fa6 Mon Sep 17 00:00:00 2001 From: allencloud Date: Thu, 17 Nov 2016 11:12:21 +0800 Subject: [PATCH] judge manager before unlocking Signed-off-by: allencloud (cherry picked from commit 972a246c671b52786a5e57743babfcf7b5b5ae99) Signed-off-by: Victor Vieux --- daemon/cluster/cluster.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/daemon/cluster/cluster.go b/daemon/cluster/cluster.go index 207d03fc6e..44e201bf52 100644 --- a/daemon/cluster/cluster.go +++ b/daemon/cluster/cluster.go @@ -587,6 +587,15 @@ func (c *Cluster) GetUnlockKey() (string, error) { // UnlockSwarm provides a key to decrypt data that is encrypted at rest. func (c *Cluster) UnlockSwarm(req types.UnlockRequest) error { + c.RLock() + if !c.isActiveManager() { + if err := c.errNoManager(); err != ErrSwarmLocked { + c.RUnlock() + return err + } + } + c.RUnlock() + key, err := encryption.ParseHumanReadableKey(req.UnlockKey) if err != nil { return err