Adds back the port shuffle on agent start retries.

This commit is contained in:
James Phillips 2017-06-02 20:53:20 -07:00
parent 9c8f656a29
commit b4b5036dfb
No known key found for this signature in database
GPG Key ID: 77183E682AC5FC11
1 changed files with 12 additions and 4 deletions

View File

@ -120,11 +120,9 @@ func (a *TestAgent) Start() *TestAgent {
} }
id := UniqueID() id := UniqueID()
// since the ports are written into the data files we pick random ports
// only once and try a number of times to start with them.
pickRandomPorts(a.Config)
for i := 10; i >= 0; i-- { for i := 10; i >= 0; i-- {
pickRandomPorts(a.Config)
// write the keyring // write the keyring
if a.Key != "" { if a.Key != "" {
writeKey := func(key, filename string) { writeKey := func(key, filename string) {
@ -163,6 +161,16 @@ func (a *TestAgent) Start() *TestAgent {
fmt.Println(id, a.Name, "retrying in", wait) fmt.Println(id, a.Name, "retrying in", wait)
time.Sleep(wait) time.Sleep(wait)
} }
// Clean out the data dir if we are responsible for it before we
// try again, since the old ports may have gotten written to
// the data dir, such as in the Raft configuration.
if a.DataDir != "" {
if err := os.RemoveAll(a.DataDir); err != nil {
fmt.Println(id, a.Name, "Error resetting data dir:", err)
runtime.Goexit()
}
}
} }
if !a.NoInitialSync { if !a.NoInitialSync {
a.Agent.StartSync() a.Agent.StartSync()