judge manager before unlocking

Signed-off-by: allencloud <allen.sun@daocloud.io>
Upstream-commit: 972a246c671b52786a5e57743babfcf7b5b5ae99
Component: engine
This commit is contained in:
allencloud
2016-11-18 23:49:40 +08:00
parent 8b84a1af7f
commit 7534114314
@@ -585,6 +585,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