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

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

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

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)