judge manager if locked before parsing key

Signed-off-by: allencloud <allen.sun@daocloud.io>
This commit is contained in:
allencloud 2016-11-21 16:33:46 +08:00
parent 103f2e56bf
commit 89100c162b
1 changed files with 5 additions and 5 deletions

View File

@ -592,6 +592,11 @@ func (c *Cluster) UnlockSwarm(req types.UnlockRequest) error {
return err return err
} }
} }
if c.node != nil || c.locked != true {
c.RUnlock()
return errors.New("swarm is not locked")
}
c.RUnlock() c.RUnlock()
key, err := encryption.ParseHumanReadableKey(req.UnlockKey) key, err := encryption.ParseHumanReadableKey(req.UnlockKey)
@ -600,11 +605,6 @@ func (c *Cluster) UnlockSwarm(req types.UnlockRequest) error {
} }
c.Lock() c.Lock()
if c.node != nil || c.locked != true {
c.Unlock()
return errors.New("swarm is not locked")
}
config := *c.lastNodeConfig config := *c.lastNodeConfig
config.lockKey = key config.lockKey = key
n, err := c.startNewNode(config) n, err := c.startNewNode(config)