Skip to content

Commit

Permalink
Fix cluster-wide Kafka client bug (#14857)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrsMark authored Nov 29, 2019
1 parent b1e53e4 commit 6c279eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions metricbeat/module/kafka/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ func (b *Broker) Connect() error {
return errors.Wrap(err, "broker.Open failed")
}

c, err := getClusterWideClient(b.Addr(), b.cfg)
if err != nil {
closeBroker(b.broker)
return fmt.Errorf("Could not get cluster client for advertised broker with address %v", b.Addr())
}
b.client = c

if b.id != noID || !b.matchID {
return nil
}
Expand All @@ -138,12 +145,6 @@ func (b *Broker) Connect() error {
b.id = other.ID()
b.advertisedAddr = other.Addr()

c, err := getClusterWideClient(b.Addr(), b.cfg)
if err != nil {
closeBroker(b.broker)
return fmt.Errorf("Could not get cluster client for advertised broker with address %v", b.Addr())
}
b.client = c
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func TestFetch(t *testing.T) {
for retries := 0; retries < 3; retries++ {
data, errors = mbtest.ReportingFetchV2Error(f)
if len(data) > 0 {
break
continue
}
time.Sleep(500 * time.Millisecond)
}
Expand Down

0 comments on commit 6c279eb

Please sign in to comment.