From 9f3e94d3c37181140e1ec9314479f0a1001c7268 Mon Sep 17 00:00:00 2001 From: souravcrl Date: Wed, 23 Oct 2024 11:41:10 +0530 Subject: [PATCH] pgwire: add test build logs for upgrade secure conn Epic CRDB-41958 Additional test build logs are added to verify the step for which `maybeUpgradeToSecureConn` fails for `TestAuthenticationAndHBARules`. Release note: None --- pkg/sql/pgwire/BUILD.bazel | 1 + pkg/sql/pgwire/pre_serve.go | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/pkg/sql/pgwire/BUILD.bazel b/pkg/sql/pgwire/BUILD.bazel index bcedf3954ee3..43ef90f0eaaa 100644 --- a/pkg/sql/pgwire/BUILD.bazel +++ b/pkg/sql/pgwire/BUILD.bazel @@ -61,6 +61,7 @@ go_library( "//pkg/sql/sqltelemetry", "//pkg/sql/types", "//pkg/util", + "//pkg/util/buildutil", "//pkg/util/ctxlog", "//pkg/util/duration", "//pkg/util/envutil", diff --git a/pkg/sql/pgwire/pre_serve.go b/pkg/sql/pgwire/pre_serve.go index 66d1d81f86c1..77cc43ae92d2 100644 --- a/pkg/sql/pgwire/pre_serve.go +++ b/pkg/sql/pgwire/pre_serve.go @@ -23,6 +23,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgwirebase" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgwirecancel" + "github.com/cockroachdb/cockroach/pkg/util/buildutil" "github.com/cockroachdb/cockroach/pkg/util/log" "github.com/cockroachdb/cockroach/pkg/util/metric" "github.com/cockroachdb/cockroach/pkg/util/mon" @@ -447,6 +448,10 @@ func (s *PreServeConnHandler) maybeUpgradeToSecureConn( // non-TLS SQL conns. if !s.cfg.AcceptSQLWithoutTLS && connType != hba.ConnLocal && connType != hba.ConnInternalLoopback { clientErr = pgerror.New(pgcode.ProtocolViolation, ErrSSLRequired) + // Extra logs under test to debug TestAuthenticationAndHBARules. + if buildutil.CrdbTestBuild { + log.Warningf(ctx, "client cannot connect since version=%d AcceptSQLWithoutTLS=false and connType=%s", version, connType) + } } return } @@ -458,6 +463,10 @@ func (s *PreServeConnHandler) maybeUpgradeToSecureConn( // we don't want it. clientErr = pgerror.New(pgcode.ProtocolViolation, "cannot use SSL/TLS over local connections") + // Extra logs under test to debug TestAuthenticationAndHBARules. + if buildutil.CrdbTestBuild { + log.Warningf(ctx, "client cannot connect since version=%d and connType=%s", version, connType) + } return } @@ -479,6 +488,10 @@ func (s *PreServeConnHandler) maybeUpgradeToSecureConn( if tlsConfig == nil { // We don't have a TLS configuration available, so we can't honor // the client's request. + // Extra logs under test to debug TestAuthenticationAndHBARules. + if buildutil.CrdbTestBuild { + log.Infof(ctx, "sending sslUnsupported message to client") + } n, serverErr = conn.Write(sslUnsupported) if serverErr != nil { return