Skip to content

Commit 294176c

Browse files
committed
Fix chainingBootstrapper to return the first successful address list
Avoids infinite recursion when the chain includes an agentBootstrapper with a server address that points back at this node (via join address loop or external LB) Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
1 parent c6c1037 commit 294176c

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

pkg/spegel/bootstrap.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ type chainingBootstrapper struct {
214214
}
215215

216216
// NewChainingBootstrapper returns a p2p bootstrapper that passes through to a list of bootstrappers.
217-
// Addressess are returned from all boostrappers that return successfully.
217+
// Addressess are returned from the first bootstrapper that returns successfully, to prevent infinite
218+
// recursion if this chains through an agentBootstrapper when the server URL is set to an external
219+
// loadbalancer that points back at this node.
218220
func NewChainingBootstrapper(bootstrappers ...routing.Bootstrapper) routing.Bootstrapper {
219221
return &chainingBootstrapper{
220222
bootstrappers: bootstrappers,
@@ -234,20 +236,16 @@ func (c *chainingBootstrapper) Run(ctx context.Context, id string) error {
234236

235237
func (c *chainingBootstrapper) Get(ctx context.Context) ([]peer.AddrInfo, error) {
236238
errs := merr.Errors{}
237-
addrs := []peer.AddrInfo{}
238239
for i := range c.bootstrappers {
239240
b := c.bootstrappers[i]
240241
as, err := b.Get(ctx)
241242
if err != nil {
242243
errs = append(errs, err)
243244
} else {
244-
addrs = append(addrs, as...)
245+
return as, nil
245246
}
246247
}
247-
if len(addrs) == 0 {
248-
return nil, merr.NewErrors(errs...)
249-
}
250-
return addrs, nil
248+
return nil, merr.NewErrors(errs...)
251249
}
252250

253251
func waitForDone(ctx context.Context) error {

0 commit comments

Comments
 (0)