Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Kafka output panic at startup #41824

Merged
merged 8 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libbeat/outputs/kafka/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func newKafkaClient(
return c, nil
}

func (c *client) Connect() error {
func (c *client) Connect(_ context.Context) error {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you revert this change and run the integration test, it will fail with the panic in the original issue.

c.mux.Lock()
defer c.mux.Unlock()

Expand Down
2 changes: 1 addition & 1 deletion libbeat/outputs/redis/backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
}

func (b *backoffClient) Connect(ctx context.Context) error {
err := b.client.Connect()
err := b.client.Connect(ctx)
if err != nil {
// give the client a chance to promote an internal error to a network error.
b.updateFailReason(err)
Expand Down Expand Up @@ -102,7 +102,7 @@
return
}

if _, ok := err.(redis.Error); ok {

Check failure on line 105 in libbeat/outputs/redis/backoff.go

View workflow job for this annotation

GitHub Actions / lint (linux)

type assertion on error will fail on wrapped errors. Use errors.As to check for specific errors (errorlint)
b.reason = failRedis
} else {
b.reason = failOther
Expand Down
2 changes: 1 addition & 1 deletion libbeat/outputs/redis/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func newClient(
}
}

func (c *client) Connect() error {
func (c *client) Connect(_ context.Context) error {
c.log.Debug("connect")
err := c.Client.Connect()
if err != nil {
Expand Down
Loading