Skip to content

kvtenant: move kv tenant connector out of ccl#98203

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
herkolategan:hbl/move-kvconnector
Apr 12, 2023
Merged

kvtenant: move kv tenant connector out of ccl#98203
craig[bot] merged 1 commit intocockroachdb:masterfrom
herkolategan:hbl/move-kvconnector

Conversation

@herkolategan
Copy link
Copy Markdown
Collaborator

@herkolategan herkolategan commented Mar 8, 2023

This change moves the kv tenant connector out of kvtenantccl to enable wider
test coverage of multi-tenant outside ccl. There are now two versions of the
kv tenant connector factory, one that provides a connector that only connects
clients to a loopback address, and another that will allow both loopback and
remote addresses. If the loopback version is used in the wrong context an error
will be returned explaining license requirements.

To assist with testing, utilities have been added to instantiate the required kv
connector factory. Tests requiring a kv connector that can connect to remote
nodes can use a testing only factory that is available outside ccl. Existing
tests that fell into this category, and depended on ccl, have been updated to
use the appropriate utility and connector.

This change does not yet remove the license check for maybe starting a tenant
when a test server is started, since this will most likely break various
existing tests and will require a larger change to fix, it will be done
separately.

Additionally, there are a few other places where TenantKVAddrs is populated
with a loopback address, and we can rather favour the new TenantLoopbackAddr
to better let the connector factory know that it's only making a loopback
connection and choose the correct logic accordingly. This will be implemented as
part of the test changes mentioned above.

Resolves: #98226
Epic: CRDB-16091

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@herkolategan herkolategan force-pushed the hbl/move-kvconnector branch 2 times, most recently from ed01a6a to a523e3d Compare March 8, 2023 17:30
@knz knz added the A-multitenancy Related to multi-tenancy label Mar 8, 2023
@herkolategan herkolategan force-pushed the hbl/move-kvconnector branch from a523e3d to e5d304f Compare March 8, 2023 19:51
@herkolategan herkolategan requested a review from knz March 10, 2023 13:32
@herkolategan herkolategan force-pushed the hbl/move-kvconnector branch 4 times, most recently from 58ee2a7 to 831d839 Compare March 14, 2023 11:24
@herkolategan herkolategan marked this pull request as ready for review March 14, 2023 13:11
@herkolategan herkolategan requested review from a team as code owners March 14, 2023 13:11
@herkolategan herkolategan requested a review from a team March 14, 2023 13:11
@herkolategan herkolategan requested a review from a team as a code owner March 14, 2023 13:11
@herkolategan herkolategan requested a review from a team March 14, 2023 13:11
@herkolategan herkolategan requested a review from a team as a code owner March 14, 2023 13:11
@herkolategan herkolategan requested a review from cucaroach March 14, 2023 13:11
@cucaroach cucaroach removed their request for review March 14, 2023 21:28
@herkolategan herkolategan marked this pull request as draft March 17, 2023 13:47
@herkolategan herkolategan force-pushed the hbl/move-kvconnector branch from 831d839 to 526b708 Compare March 17, 2023 13:47
@herkolategan herkolategan marked this pull request as ready for review March 17, 2023 14:54
@herkolategan herkolategan force-pushed the hbl/move-kvconnector branch 4 times, most recently from 4d67b32 to 39863b1 Compare March 23, 2023 14:22
@knz knz added the backport-23.1.x PAST MAINTENANCE SUPPORT: 23.1 patch releases via ER request only label Apr 10, 2023
Copy link
Copy Markdown
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent, thanks. I have only a few comments. Let's rebase this and have a look at CI before this can merge.

Reviewed 25 of 41 files at r1, 2 of 7 files at r2, 1 of 1 files at r4, 4 of 11 files at r5, 15 of 15 files at r6, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @herkolategan)


pkg/kv/kvclient/kvtenant/connector.go line 139 at r6 (raw file):

// connector mediates the communication of cluster-wide state to sandboxed
// SQL-only tenant processes through a restricted interface.

through this comment and the other comments below replace "process" by "server".


pkg/kv/kvclient/kvtenant/connector.go line 143 at r6 (raw file):

// A connector is instantiated inside a tenant's SQL process and is seeded with
// a set of one or more network addresses that reference existing KV nodes in
// the host cluster (or a load-balancer which fans out to some/all KV nodes). On

s/host/storage, here and below


pkg/kv/kvclient/kvtenant/connector.go line 148 at r6 (raw file):

// communication.
//
// The connector communicates with the host cluster through the roachpb.Internal

s/host/storage


pkg/kv/kvclient/kvtenant/connector.go line 191 at r6 (raw file):

// connector is capable of providing information on each of the KV nodes in the
// cluster in the form of NodeDescriptors. This obviates the need for SQL-only

replace "SQL-only tenant processes" to "tenant SQL servers", here and below.


pkg/kv/kvclient/kvtenant/connector_factory.go line 36 at r6 (raw file):

}

type KVAddressConfig struct {

I think this needs a docstring.

This change moves the kv tenant connector out of `kvtenantccl` to enable wider
test coverage of multi-tenant outside `ccl`. There are now two versions of the
kv tenant connector factory, one that provides a connector that only connects
clients to a loopback address, and another that will allow both loopback and
remote addresses. If the loopback version is used in the wrong context an error
will be returned explaining license requirements.

To assist with testing, utilities have been added to instantiate the required kv
connector factory. Tests requiring a kv connector that can connect to remote
nodes can use a testing only factory that is available outside `ccl`. Existing
tests that fell into this category, and depended on `ccl`, have been updated to
use the appropriate utility and connector.

This change does not yet remove the license check for maybe starting a tenant
when a test server is started, since this will most likely break various
existing tests and will require a larger change to fix, it will be done
separately.

Additionally, there are a few other places where `TenantKVAddrs` is populated
with a loopback address, and we can rather favour the new `TenantLoopbackAddr`
to better let the connector factory know that it's only making a loopback
connection and choose the correct logic accordingly. This will be implemented as
part of the test changes mentioned above.

Resolves: cockroachdb#98226
Epic: CRDB-16091
@herkolategan herkolategan force-pushed the hbl/move-kvconnector branch from 39863b1 to 29edf81 Compare April 11, 2023 12:29
Copy link
Copy Markdown
Collaborator Author

@herkolategan herkolategan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@knz Thanks for the excellent review! Addressing the comments and doing a rebase. During the rebase I saw that there are two new ccl packages that added tests under kvtenantccl. I have decided to leave those there, unless instructed otherwise.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @knz)


pkg/kv/kvclient/kvtenant/connector.go line 139 at r6 (raw file):

Previously, knz (Raphael 'kena' Poss) wrote…

through this comment and the other comments below replace "process" by "server".

Done.


pkg/kv/kvclient/kvtenant/connector.go line 143 at r6 (raw file):

Previously, knz (Raphael 'kena' Poss) wrote…

s/host/storage, here and below

Done.


pkg/kv/kvclient/kvtenant/connector.go line 148 at r6 (raw file):

Previously, knz (Raphael 'kena' Poss) wrote…

s/host/storage

Done.


pkg/kv/kvclient/kvtenant/connector.go line 191 at r6 (raw file):

Previously, knz (Raphael 'kena' Poss) wrote…

replace "SQL-only tenant processes" to "tenant SQL servers", here and below.

Done.


pkg/kv/kvclient/kvtenant/connector_factory.go line 36 at r6 (raw file):

Previously, knz (Raphael 'kena' Poss) wrote…

I think this needs a docstring.

True, adding.

@herkolategan herkolategan requested a review from knz April 11, 2023 14:02
Copy link
Copy Markdown
Contributor

@knz knz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

We can move tests in a later PR.

Reviewed 27 of 27 files at r7, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained

@herkolategan
Copy link
Copy Markdown
Collaborator Author

bors r=knz

1 similar comment
@herkolategan
Copy link
Copy Markdown
Collaborator Author

bors r=knz

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Apr 12, 2023

Timed out.

@knz
Copy link
Copy Markdown
Contributor

knz commented Apr 12, 2023

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Apr 12, 2023

Timed out.

@knz
Copy link
Copy Markdown
Contributor

knz commented Apr 12, 2023

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Apr 12, 2023

Build failed:

@herkolategan
Copy link
Copy Markdown
Collaborator Author

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Apr 12, 2023

Build succeeded:

@craig craig bot merged commit 372cf8d into cockroachdb:master Apr 12, 2023
@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Apr 12, 2023

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from 29edf81 to blathers/backport-release-23.1-98203: POST https://api.github.com/repos/cockroachdb/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 23.1.x failed. See errors above.


🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@knz
Copy link
Copy Markdown
Contributor

knz commented Apr 12, 2023

@herkolategan I think you will need to issue the backport manually?

@herkolategan
Copy link
Copy Markdown
Collaborator Author

@knz yip, seems like this one needs to be done manually, I'll get on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-multitenancy Related to multi-tenancy backport-23.1.x PAST MAINTENANCE SUPPORT: 23.1 patch releases via ER request only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kvtenant: move kv tenant connector out of ccl

3 participants