tiny cleanup
Some checks failed
Build and Publish / BuildAndDeployAmd64 (push) Failing after 19s
Build and Publish / BuildAndDeploy (push) Has been cancelled

This commit is contained in:
matst80
2024-11-12 21:40:17 +01:00
parent 6abd818ed6
commit 3a75a84fb1

View File

@@ -351,24 +351,13 @@ func (p *SyncedPool) removeLocalGrain(id CartId) {
delete(p.local.grains, id) delete(p.local.grains, id)
} }
func (p *SyncedPool) addRemoteHost(address string, remote *RemoteHost) error { func (p *SyncedPool) addRemoteHost(address string, remote *RemoteHost) {
known := make([]string, 0, len(p.remotes)+1)
for _, r := range p.remotes {
known = append(known, r.Host)
if r.Host == address {
log.Printf("Remote %s already exists\n", address)
return fmt.Errorf("remote %s already exists", address)
}
}
known = append([]string{p.Hostname}, known...)
p.remotes = append(p.remotes, remote) p.remotes = append(p.remotes, remote)
connectedRemotes.Set(float64(len(p.remotes))) connectedRemotes.Set(float64(len(p.remotes)))
log.Printf("Added remote %s\n", remote.Host) log.Printf("Added remote %s\n", remote.Host)
go remote.Initialize(p) go remote.Initialize(p)
return nil
} }
func (p *SyncedPool) AddRemote(host string) error { func (p *SyncedPool) AddRemote(host string) error {
@@ -380,12 +369,6 @@ func (p *SyncedPool) AddRemote(host string) error {
log.Printf("Error connecting to remote %s: %v\n", host, err) log.Printf("Error connecting to remote %s: %v\n", host, err)
return err return err
} }
_, err = client.Call(Ping, Pong, []byte{})
if err != nil {
log.Printf("No response from new remote %s", host)
return err
}
remote := RemoteHost{ remote := RemoteHost{
Client: client, Client: client,
@@ -404,10 +387,10 @@ func (p *SyncedPool) AddRemote(host string) error {
for err != nil { for err != nil {
time.Sleep(time.Millisecond * 200) time.Sleep(time.Millisecond * 200)
err = remote.Ping() err = remote.Ping()
if remote.MissedPings > 3 { if !remote.IsHealthy() {
log.Printf("Removing host, unable to communicate with %s", host) log.Printf("Removing host, unable to communicate with %s", host)
p.RemoveHost(&remote) p.RemoveHost(&remote)
return break
} }
} }
} }