Skip to content

Commit

Permalink
return an error if the update list is empty, might be a transient err…
Browse files Browse the repository at this point in the history
…or, logged in discovery
  • Loading branch information
Anaethelion committed Apr 30, 2024
1 parent e562923 commit dffd96a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions elastictransport/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ func (cp *statusConnectionPool) OnFailure(c *Connection) error {
// Update merges the existing live and dead connections with the latest nodes discovered from the cluster.
// ConnectionPool must be locked before calling.
func (cp *statusConnectionPool) Update(connections []*Connection) error {
if len(connections) == 0 {
return errors.New("no connections provided, connection pool left untouched")
}

// Remove hosts that are no longer in the new list of connections
for i := 0; i < len(cp.live); i++ {
found := false
Expand Down
4 changes: 3 additions & 1 deletion elastictransport/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ func (c *Client) DiscoverNodes() error {
if p, ok := c.pool.(UpdatableConnectionPool); ok {
err = p.Update(conns)
if err != nil {
return err
if debugLogger != nil {
debugLogger.Logf("Error updating pool: %s\n", err)
}
}
} else {
c.pool, err = NewConnectionPool(conns, c.selector)
Expand Down

0 comments on commit dffd96a

Please sign in to comment.