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

release-24.3: pgwire: add test build logs for upgrade secure conn #133229

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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