Merge pull request #28649 from allencloud/judge-locked-before-parsing-key

judge manager if locked before parsing key
Upstream-commit: 6e4a3c4546d50558d273f8ead7b8ee42ea9f9f20
Component: engine
This commit is contained in:
Victor Vieux
2016-11-21 13:33:38 -08:00
committed by GitHub

View File

@ -592,6 +592,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)
@ -600,11 +605,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)