watch deletes
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 1m58s
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 1m58s
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
"k8s.io/apimachinery/pkg/watch"
|
||||
)
|
||||
|
||||
type Quorum interface {
|
||||
@@ -183,18 +184,29 @@ func NewSyncedPool(local *GrainLocalPool, hostname string, discovery Discovery)
|
||||
log.Printf("Error discovering hosts: %v", err)
|
||||
return
|
||||
}
|
||||
for host := range ch {
|
||||
if pool.IsKnown(host) || host == "" {
|
||||
for chng := range ch {
|
||||
if chng.Host == "" {
|
||||
continue
|
||||
}
|
||||
go func(h string) {
|
||||
log.Printf("Discovered host %s, waiting for startup", h)
|
||||
time.Sleep(time.Second)
|
||||
err := pool.AddRemote(h)
|
||||
if err != nil {
|
||||
log.Printf("Error adding remote %s: %v", h, err)
|
||||
known := pool.IsKnown(chng.Host)
|
||||
if chng.Type == watch.Added && !known {
|
||||
go func(h string) {
|
||||
log.Printf("Discovered host %s, waiting for startup", h)
|
||||
time.Sleep(time.Second)
|
||||
err := pool.AddRemote(h)
|
||||
if err != nil {
|
||||
log.Printf("Error adding remote %s: %v", h, err)
|
||||
}
|
||||
}(chng.Host)
|
||||
} else if chng.Type == watch.Deleted && known {
|
||||
log.Printf("Host removed %s, removing from index", chng.Host)
|
||||
for _, r := range pool.remotes {
|
||||
if r.Host == chng.Host {
|
||||
pool.RemoveHost(r)
|
||||
break
|
||||
}
|
||||
}
|
||||
}(host)
|
||||
}
|
||||
}
|
||||
}()
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user