Skip to content

Commit

Permalink
Merge pull request #133229 from souravcrl/backport24.3-133224
Browse files Browse the repository at this point in the history
release-24.3: pgwire: add test build logs for upgrade secure conn
  • Loading branch information
rafiss authored Oct 24, 2024
2 parents 40c7566 + a71f444 commit 8a8bba8
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 @@ -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",
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 @@ -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"
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}

Expand All @@ -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
Expand Down

0 comments on commit 8a8bba8

Please sign in to comment.