Skip to content

multitenant: make the system tenant appear to have all capabilities#105146

Merged
craig[bot] merged 2 commits intocockroachdb:masterfrom
knz:20230619-system-caps
Jun 21, 2023
Merged

multitenant: make the system tenant appear to have all capabilities#105146
craig[bot] merged 2 commits intocockroachdb:masterfrom
knz:20230619-system-caps

Conversation

@knz
Copy link
Copy Markdown
Contributor

@knz knz commented Jun 19, 2023

Epic: CRDB-26691
Fixes #98749.

The system tenant is currently defined to have access to all services.
Yet, the output of SHOW TENANT system WITH CAPABILITIES suggested
that was not true.

This patch fixes that.

@knz knz requested review from stevendanna and yuzefovich June 19, 2023 14:47
@knz knz requested review from a team as code owners June 19, 2023 14:47
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@knz knz added backport-23.1.x PAST MAINTENANCE SUPPORT: 23.1 patch releases via ER request only A-multitenancy Related to multi-tenancy labels Jun 19, 2023
@knz knz force-pushed the 20230619-system-caps branch from 1d92fcc to 7e0fd34 Compare June 20, 2023 10:36
Copy link
Copy Markdown
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

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

I only have a couple of questions for my own edification.

:lgtm:

Reviewed 4 of 4 files at r1, 5 of 5 files at r2, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @knz and @stevendanna)


pkg/multitenant/tenantcapabilities/capabilities.go line 21 at r2 (raw file):

// ID represents a handle to a tenant capability.
type ID uint8

Just curious what was the rationale for choosing uint8 here. It seems feasible (although improbable) that we'll have more than 256 capabilities in the future. Is the size of ID important optimization? Is there an RFC or some PR I could read about it?


pkg/ccl/logictestccl/testdata/logic_test/tenant_capability line 221 at r2 (raw file):

subtest regression_98749

query TT colnames

nit: I wonder whether we should add rowsort option or ORDER BY to the query to ensure deterministic output.


pkg/multitenant/tenantcapabilities/values_test.go line 34 at r1 (raw file):

}

func TestGetSet(t *testing.T) {

Do you know what the purpose of this test is? That it doesn't panic?

@knz knz force-pushed the 20230619-system-caps branch from 7e0fd34 to d4a8293 Compare June 21, 2023 13:28
Copy link
Copy Markdown
Contributor Author

@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.

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @stevendanna and @yuzefovich)


pkg/multitenant/tenantcapabilities/capabilities.go line 21 at r2 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

Just curious what was the rationale for choosing uint8 here. It seems feasible (although improbable) that we'll have more than 256 capabilities in the future. Is the size of ID important optimization? Is there an RFC or some PR I could read about it?

It's a general principle I learned from Radu: use the smallest type large enough for an enum. It ensures that structs that embed a field of this type don't get unnecessary large.

For further discussion, I would just ping folk on #go-learners.

NB that if the type ever becomes "too small" we'd immediately become alerted by unit tests.


pkg/ccl/logictestccl/testdata/logic_test/tenant_capability line 221 at r2 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

nit: I wonder whether we should add rowsort option or ORDER BY to the query to ensure deterministic output.

let's do it. Done.


pkg/multitenant/tenantcapabilities/values_test.go line 34 at r1 (raw file):

Previously, yuzefovich (Yahor Yuzefovich) wrote…

Do you know what the purpose of this test is? That it doesn't panic?

It's to ensure the default value has a representation and is settable. Added a comment to clarify.

@knz
Copy link
Copy Markdown
Contributor Author

knz commented Jun 21, 2023

bors r=yuzefovich

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jun 21, 2023

Build failed (retrying...):

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jun 21, 2023

Build failed:

@knz
Copy link
Copy Markdown
Contributor Author

knz commented Jun 21, 2023

bors r=yuzefovich

@knz knz force-pushed the 20230619-system-caps branch from d4a8293 to c59c04b Compare June 21, 2023 14:26
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jun 21, 2023

Canceled.

@knz
Copy link
Copy Markdown
Contributor Author

knz commented Jun 21, 2023

bors r=yuzefovich

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jun 21, 2023

Build failed:

knz added 2 commits June 21, 2023 17:42
This struct was ill-defined: what does it mean for a cap struct to be
"default"? Default relative to what?

There are only two things that matter:
- the empty protobuf, which is the actual implementation default.
- whichever set of capabilities is taken over from a template
  in CREATE TENANT ... LIKE.

In fact, `DefaultCapabilities` so far was only used in tests.
This commit removes it, to avoid any confusion.

Release note: None
The system tenant is currently defined to have access to all services.
Yet, the output of `SHOW TENANT system WITH CAPABILITIES` suggested
that was not true.

This patch fixes that.

Release note: None
@knz knz force-pushed the 20230619-system-caps branch from c59c04b to 7ab3e49 Compare June 21, 2023 15:43
@knz
Copy link
Copy Markdown
Contributor Author

knz commented Jun 21, 2023

bors r=yuzefovich

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jun 21, 2023

Build succeeded:

@craig craig bot merged commit 7cb2a89 into cockroachdb:master Jun 21, 2023
@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Jun 21, 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 7ab3e49 to blathers/backport-release-23.1-105146: 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 knz deleted the 20230619-system-caps branch June 22, 2023 19:21
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.

sql: the output of SHOW TENANT system WITH CAPABILITIES is nonsensical

3 participants