Skip to content

Commit 0f5abad

Browse files
craig[bot]yuzefovich
andcommitted
Merge #155742
155742: server: fix SetAcceptSQLWithoutTLS for shared-process deployments r=yuzefovich a=yuzefovich We expose `SetAcceptSQLWithoutTLS` method on the test servers which allows us to tweak whether SQL clients can authenticate without TLS on a secure cluster. Previously, this method was incorrect for shared-process deployments, and this is now fixed. The notable distinction between this mode and single-tenant and external-process modes is that even though the shared-process tenant has its own copy of `base.Config` (where `AcceptSQLWithoutTLS` is stored), it does _not_ have its own pre-serve handler. In other words, before the authentication is performed, the connection is handled by the _system_ tenant, so for things to work we need to propagate the update of the boolean to the system tenant. Fixes: #112961. Epic: CRDB-48945 Release note: None Co-authored-by: Yahor Yuzefovich <yahor@cockroachlabs.com>
2 parents cb68f89 + 8f5e8eb commit 0f5abad

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

pkg/server/server_controller_new_server.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ func makeSharedProcessTenantServerConfig(
238238
baseCfg.Config.Insecure = kvServerCfg.Config.Insecure
239239
baseCfg.Config.User = kvServerCfg.Config.User
240240
baseCfg.Config.DisableTLSForHTTP = kvServerCfg.Config.DisableTLSForHTTP
241+
// Note that since the shared-process tenant doesn't have its own pre-serve
242+
// handler, only AcceptSQLWithoutTLS of the _system_ tenant matters, so this
243+
// particular inherited value is meaningless, but we choose to keep it for
244+
// consistency with the system tenant.
241245
baseCfg.Config.AcceptSQLWithoutTLS = kvServerCfg.Config.AcceptSQLWithoutTLS
242246
baseCfg.Config.RPCHeartbeatInterval = kvServerCfg.Config.RPCHeartbeatInterval
243247
baseCfg.Config.RPCHeartbeatTimeout = kvServerCfg.Config.RPCHeartbeatTimeout

pkg/server/testserver.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,6 +1553,11 @@ func (t *testTenant) SetReady(ready bool) {
15531553
// SetAcceptSQLWithoutTLS is part of the serverutils.ApplicationLayerInterface.
15541554
func (t *testTenant) SetAcceptSQLWithoutTLS(accept bool) {
15551555
t.Cfg.AcceptSQLWithoutTLS = accept
1556+
// If we're running in a shared-process mode, the pre-serve handler has its
1557+
// own copy of base.Config (that is shared with the system tenant), so we
1558+
// must propagate the updated value there too. (For other deployments this
1559+
// call is redundant with the update above but otherwise harmless.)
1560+
t.pgPreServer.TestingSetAcceptSQLWithoutTLS(accept)
15561561
}
15571562

15581563
// PrivilegeChecker is part of the serverutils.ApplicationLayerInterface.

pkg/sql/pgwire/auth_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -872,12 +872,6 @@ func TestSSLSessionVar(t *testing.T) {
872872
t.Fatal(err)
873873
}
874874

875-
// Set the system layer to accept SQL without TLS in the event of a shared
876-
// process virtual cluster.
877-
srv.SystemLayer().SetAcceptSQLWithoutTLS(true)
878-
879-
// TODO(herko): What effect should this have on a shared process virtual
880-
// cluster? See: https://github.com/cockroachdb/cockroach/issues/112961
881875
s.SetAcceptSQLWithoutTLS(true)
882876

883877
pgURLWithCerts, cleanupFuncCerts := s.PGUrl(t,

pkg/sql/pgwire/pre_serve.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ func (s *PreServeConnHandler) AnnotateCtxForIncomingConn(
172172
return logtags.AddTag(ctx, tag, conn.RemoteAddr().String())
173173
}
174174

175+
// TestingSetAcceptSQLWithoutTLS updates the config to tweak whether SQL clients
176+
// can authenticate without TLS on a secure cluster, in tests.
177+
func (s *PreServeConnHandler) TestingSetAcceptSQLWithoutTLS(accept bool) {
178+
s.cfg.AcceptSQLWithoutTLS = accept
179+
}
180+
175181
// tenantIndependentMetrics is the set of metrics for the
176182
// pre-serve part of connection handling, before the connection
177183
// is routed to a specific tenant.

0 commit comments

Comments
 (0)