Browse Source

Merge pull request #28533 from allencloud/judge-manager-first-before-unlocking

judge manager before unlocking
Tõnis Tiigi 8 years ago
parent
commit
eb0fc787e6
1 changed files with 9 additions and 0 deletions
  1. 9 0
      daemon/cluster/cluster.go

+ 9 - 0
daemon/cluster/cluster.go

@@ -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