mirror of https://github.com/status-im/consul.git
parent
6346ac34cf
commit
9ffeba18ee
|
@ -6,13 +6,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
discover "github.com/hashicorp/go-discover"
|
discover "github.com/hashicorp/go-discover"
|
||||||
|
|
||||||
// support retry-join only for the following providers
|
|
||||||
// to add more providers import additional packages or 'all'
|
|
||||||
// to support all providers of go-discover
|
|
||||||
_ "github.com/hashicorp/go-discover/provider/aws"
|
|
||||||
_ "github.com/hashicorp/go-discover/provider/azure"
|
|
||||||
_ "github.com/hashicorp/go-discover/provider/gce"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// RetryJoin is used to handle retrying a join until it succeeds or all
|
// RetryJoin is used to handle retrying a join until it succeeds or all
|
||||||
|
@ -23,7 +16,8 @@ func (a *Agent) retryJoin() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
a.logger.Printf("[INFO] agent: Supporting retry join for %v", discover.ProviderNames())
|
disco := discover.Discover{}
|
||||||
|
a.logger.Printf("[INFO] agent: Retry join is supported for: %s", strings.Join(disco.Names(), " "))
|
||||||
a.logger.Printf("[INFO] agent: Joining cluster...")
|
a.logger.Printf("[INFO] agent: Joining cluster...")
|
||||||
attempt := 0
|
attempt := 0
|
||||||
for {
|
for {
|
||||||
|
@ -33,7 +27,7 @@ func (a *Agent) retryJoin() {
|
||||||
for _, addr := range cfg.RetryJoin {
|
for _, addr := range cfg.RetryJoin {
|
||||||
switch {
|
switch {
|
||||||
case strings.Contains(addr, "provider="):
|
case strings.Contains(addr, "provider="):
|
||||||
servers, err := discover.Addrs(addr, a.logger)
|
servers, err := disco.Addrs(addr, a.logger)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.logger.Printf("[ERR] agent: %s", err)
|
a.logger.Printf("[ERR] agent: %s", err)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -7,11 +7,10 @@ import (
|
||||||
discover "github.com/hashicorp/go-discover"
|
discover "github.com/hashicorp/go-discover"
|
||||||
)
|
)
|
||||||
|
|
||||||
// if this test fails check the _ imports of go-discover/provider/* packages
|
|
||||||
// in retry_join.go
|
|
||||||
func TestGoDiscoverRegistration(t *testing.T) {
|
func TestGoDiscoverRegistration(t *testing.T) {
|
||||||
got := discover.ProviderNames()
|
d := discover.Discover{}
|
||||||
want := []string{"aws", "azure", "gce"}
|
got := d.Names()
|
||||||
|
want := []string{"aws", "azure", "gce", "softlayer"}
|
||||||
if !reflect.DeepEqual(got, want) {
|
if !reflect.DeepEqual(got, want) {
|
||||||
t.Fatalf("got go-discover providers %v want %v", got, want)
|
t.Fatalf("got go-discover providers %v want %v", got, want)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue