Skip to content

Commit e953885

Browse files
authored
[chore] internal/kafka: remove redundant warning (open-telemetry#43895)
#### Description Remove the hook that guesses that TLS is misconfigured, since franz-go now warns on the same scenario. See open-telemetry#40145 (comment) #### Link to tracking issue N/A #### Testing Updated tests #### Documentation N/A
1 parent 2dd7600 commit e953885

File tree

2 files changed

+2
-30
lines changed

2 files changed

+2
-30
lines changed

internal/kafka/franz_client.go

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@ package kafka // import "github.com/open-telemetry/opentelemetry-collector-contr
55

66
import (
77
"context"
8-
"errors"
98
"fmt"
109
"hash/fnv"
11-
"io"
12-
"net"
1310
"strings"
1411
"time"
1512

@@ -244,11 +241,6 @@ func commonOpts(ctx context.Context, clientCfg configkafka.ClientConfig,
244241
if tlsCfg != nil {
245242
opts = append(opts, kgo.DialTLSConfig(tlsCfg))
246243
}
247-
} else {
248-
// Add a hook that gives a hint that TLS is not configured
249-
// in case we try to connect to a TLS-only broker.
250-
var hook kgo.HookBrokerConnect = hookBrokerConnectPlaintext{logger: logger}
251-
opts = append(opts, kgo.WithHooks(hook))
252244
}
253245
// Configure authentication
254246
if clientCfg.Authentication.PlainText != nil {
@@ -377,24 +369,3 @@ func saramaHashFn(b []byte) uint32 {
377369
h.Write(b)
378370
return h.Sum32()
379371
}
380-
381-
type hookBrokerConnectPlaintext struct {
382-
logger *zap.Logger
383-
}
384-
385-
func (h hookBrokerConnectPlaintext) OnBrokerConnect(
386-
meta kgo.BrokerMetadata, _ time.Duration, conn net.Conn, err error,
387-
) {
388-
if conn == nil {
389-
// Could not make a network connection, this is not related to TLS.
390-
return
391-
}
392-
if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) {
393-
h.logger.Warn(
394-
"failed to connect to broker, it may require TLS but TLS is not configured",
395-
zap.String("host", meta.Host),
396-
zap.Error(err),
397-
)
398-
return
399-
}
400-
}

internal/kafka/franz_client_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@ func TestNewFranzSyncProducer_TLS(t *testing.T) {
164164
// Should fail because the server expects TLS.
165165
require.Error(t, tryConnect(nil))
166166
filtered := observedLogs.FilterMessage(
167-
"failed to connect to broker, it may require TLS but TLS is not configured",
167+
// franz-go logs this warning message:
168+
"read from broker received EOF during api versions discovery, which often happens when the broker requires TLS and the client is not using it (is TLS misconfigured?)",
168169
)
169170
assert.NotEmpty(t, filtered.All())
170171
})

0 commit comments

Comments
 (0)