Skip to content

Commit

Permalink
Merge pull request cockroachdb#133226 from souravcrl/backport23.2-133224
Browse files Browse the repository at this point in the history
release-23.2: pgwire: add test build logs for upgrade secure conn
  • Loading branch information
rafiss authored Oct 24, 2024
2 parents 529b877 + 21bacca commit 104316d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/sql/pgwire/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ go_library(
"//pkg/sql/sqltelemetry",
"//pkg/sql/types",
"//pkg/util",
"//pkg/util/buildutil",
"//pkg/util/ctxlog",
"//pkg/util/duration",
"//pkg/util/envutil",
Expand Down
13 changes: 13 additions & 0 deletions pkg/sql/pgwire/pre_serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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"
Expand Down Expand Up @@ -444,6 +445,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
}
Expand All @@ -455,6 +460,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
}

Expand All @@ -476,6 +485,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
Expand Down

0 comments on commit 104316d

Please sign in to comment.