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

Merge pull request #33341 from cyli/do-not-clear-state-on-swarm-init-join

Do not clear swarm directory on `swarm init` and `swarm join`
This commit is contained in:
Aaron Lehmann 2017-05-23 12:09:53 -07:00 committed by GitHub
commit a9fcaee351

View file

@ -88,10 +88,6 @@ func (c *Cluster) Init(req types.InitRequest) (string, error) {
}
}
if !req.ForceNewCluster {
clearPersistentState(c.root)
}
nr, err := c.newNodeRunner(nodeStartConfig{
forceNewCluster: req.ForceNewCluster,
autolock: req.AutoLockManagers,
@ -109,16 +105,14 @@ func (c *Cluster) Init(req types.InitRequest) (string, error) {
c.mu.Unlock()
if err := <-nr.Ready(); err != nil {
c.mu.Lock()
c.nr = nil
c.mu.Unlock()
if !req.ForceNewCluster { // if failure on first attempt don't keep state
if err := clearPersistentState(c.root); err != nil {
return "", err
}
}
if err != nil {
c.mu.Lock()
c.nr = nil
c.mu.Unlock()
}
return "", err
}
state := nr.State()
@ -166,8 +160,6 @@ func (c *Cluster) Join(req types.JoinRequest) error {
return err
}
clearPersistentState(c.root)
nr, err := c.newNodeRunner(nodeStartConfig{
RemoteAddr: req.RemoteAddrs[0],
ListenAddr: net.JoinHostPort(listenHost, listenPort),
@ -193,6 +185,9 @@ func (c *Cluster) Join(req types.JoinRequest) error {
c.mu.Lock()
c.nr = nil
c.mu.Unlock()
if err := clearPersistentState(c.root); err != nil {
return err
}
}
return err
}