1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

judge manager if locked before parsing key

Signed-off-by: allencloud <allen.sun@daocloud.io>
(cherry picked from commit 89100c162b)
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
This commit is contained in:
allencloud 2016-11-21 16:33:46 +08:00 committed by Victor Vieux
parent bdc378e781
commit 2ecc8cd4bd

View file

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