remove dead nodes
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 1m52s

This commit is contained in:
matst80
2024-11-09 20:17:19 +01:00
parent fa37db6f63
commit f1c3fa8240

View File

@@ -127,11 +127,19 @@ func NewSyncedPool(local *GrainLocalPool, hostname string, d Discovery) (*Synced
log.Printf("Error adding undiscovered remote %s: %v\n", h, err) log.Printf("Error adding undiscovered remote %s: %v\n", h, err)
} }
} }
for _, r := range pool.remotes { for i, r := range pool.remotes {
err := DoPing(r.connection) err := DoPing(r.connection)
if err != nil { if err != nil {
r.MissedPings++ r.MissedPings++
log.Printf("Error pinging remote %s: %v\n, missed pings: %d", r.Host, err, r.MissedPings) log.Printf("Error pinging remote %s: %v\n, missed pings: %d", r.Host, err, r.MissedPings)
if r.MissedPings > 3 {
log.Printf("Removing remote %s\n", r.Host)
pool.remotes = append(pool.remotes[:i], pool.remotes[i+1:]...)
}
} else {
r.MissedPings = 0
} }
} }
}() }()