-
Notifications
You must be signed in to change notification settings - Fork 4k
server: enable _status/connectivity for secondary tenants (shared-process)
#131830
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
Merged
craig
merged 3 commits into
cockroachdb:master
from
shubhamdhama:enable-connectivity-for-mt
Jan 15, 2025
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
pkg/ccl/changefeedccl/mocks/tenant_status_server_generated.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -192,14 +192,6 @@ func newTenantDoesNotHaveCapabilityError(cap tenantcapabilities.ID, req kvpb.Req | |
| return errors.Newf("client tenant does not have capability %q (%T)", cap, req) | ||
| } | ||
|
|
||
| var ( | ||
| errCannotQueryMetadata = errors.New("client tenant does not have capability to query cluster node metadata") | ||
| errCannotQueryTSDB = errors.New("client tenant does not have capability to query timeseries data") | ||
| errCannotQueryAllMetrics = errors.New("client tenant does not have capability to query non-tenant metrics") | ||
| errCannotUseNodelocal = errors.New("client tenant does not have capability to use nodelocal storage") | ||
| errCannotDebugProcess = errors.New("client tenant does not have capability to debug the process") | ||
| ) | ||
|
|
||
| // methodCapability associates a KV method with a capability. The capability can | ||
| // either be static for all instances of the method, or it can be determined | ||
| // dynamically by a function based on the request's contents. | ||
|
|
@@ -316,33 +308,25 @@ func (a *Authorizer) BindReader(reader tenantcapabilities.Reader) { | |
| a.capabilitiesReader = reader | ||
| } | ||
|
|
||
| func (a *Authorizer) HasNodeStatusCapability(ctx context.Context, tenID roachpb.TenantID) error { | ||
| if tenID.IsSystem() { | ||
| return nil | ||
| } | ||
| entry, mode := a.getMode(ctx, tenID) | ||
| switch mode { | ||
| case authorizerModeOn: | ||
| break | ||
| case authorizerModeAllowAll: | ||
| return nil | ||
| case authorizerModeV222: | ||
| return errCannotQueryMetadata | ||
| default: | ||
| err := errors.AssertionFailedf("unknown authorizer mode: %d", mode) | ||
| logcrash.ReportOrPanic(ctx, &a.settings.SV, "%v", err) | ||
| return err | ||
| } | ||
| var ( | ||
| errCannotQueryMetadata = errors.New("client tenant does not have capability to query cluster node metadata") | ||
| errCannotQueryTSDB = errors.New("client tenant does not have capability to query timeseries data") | ||
| errCannotQueryAllMetrics = errors.New("client tenant does not have capability to query non-tenant metrics") | ||
| errCannotUseNodelocal = errors.New("client tenant does not have capability to use nodelocal storage") | ||
| errCannotDebugProcess = errors.New("client tenant does not have capability to debug the process") | ||
| ) | ||
|
|
||
| if !tenantcapabilities.MustGetBoolByID( | ||
| entry.TenantCapabilities, tenantcapabilities.CanViewNodeInfo, | ||
| ) { | ||
| return errCannotQueryMetadata | ||
| } | ||
| return nil | ||
| var insufficientCapErrMap = map[tenantcapabilities.ID]error{ | ||
| tenantcapabilities.CanViewNodeInfo: errCannotQueryMetadata, | ||
| tenantcapabilities.CanViewTSDBMetrics: errCannotQueryTSDB, | ||
| tenantcapabilities.CanUseNodelocalStorage: errCannotUseNodelocal, | ||
| tenantcapabilities.CanDebugProcess: errCannotDebugProcess, | ||
| tenantcapabilities.CanViewAllMetrics: errCannotQueryAllMetrics, | ||
| } | ||
|
|
||
| func (a *Authorizer) HasTSDBQueryCapability(ctx context.Context, tenID roachpb.TenantID) error { | ||
| func (a *Authorizer) hasCapability( | ||
| ctx context.Context, tenID roachpb.TenantID, cap tenantcapabilities.ID, | ||
| ) error { | ||
| if tenID.IsSystem() { | ||
| return nil | ||
| } | ||
|
|
@@ -354,47 +338,41 @@ func (a *Authorizer) HasTSDBQueryCapability(ctx context.Context, tenID roachpb.T | |
| case authorizerModeAllowAll: | ||
| return nil | ||
| case authorizerModeV222: | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we should do a cleanup and remove this setting option in a separate PR |
||
| return errCannotQueryTSDB | ||
| return insufficientCapErrMap[cap] | ||
| default: | ||
| err := errors.AssertionFailedf("unknown authorizer mode: %d", mode) | ||
| logcrash.ReportOrPanic(ctx, &a.settings.SV, "%v", err) | ||
| return err | ||
| } | ||
|
|
||
| if !tenantcapabilities.MustGetBoolByID( | ||
| entry.TenantCapabilities, tenantcapabilities.CanViewTSDBMetrics, | ||
| ) { | ||
| return errCannotQueryTSDB | ||
| if !tenantcapabilities.MustGetBoolByID(entry.TenantCapabilities, cap) { | ||
| return insufficientCapErrMap[cap] | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (a *Authorizer) HasNodeStatusCapability(ctx context.Context, tenID roachpb.TenantID) error { | ||
| return a.hasCapability(ctx, tenID, tenantcapabilities.CanViewNodeInfo) | ||
| } | ||
|
|
||
| func (a *Authorizer) HasTSDBQueryCapability(ctx context.Context, tenID roachpb.TenantID) error { | ||
| return a.hasCapability(ctx, tenID, tenantcapabilities.CanViewTSDBMetrics) | ||
| } | ||
|
|
||
| func (a *Authorizer) HasNodelocalStorageCapability( | ||
| ctx context.Context, tenID roachpb.TenantID, | ||
| ) error { | ||
| if tenID.IsSystem() { | ||
| return nil | ||
| } | ||
| entry, mode := a.getMode(ctx, tenID) | ||
| switch mode { | ||
| case authorizerModeOn: | ||
| break | ||
| case authorizerModeAllowAll: | ||
| return nil | ||
| case authorizerModeV222: | ||
| return errCannotUseNodelocal | ||
| default: | ||
| err := errors.AssertionFailedf("unknown authorizer mode: %d", mode) | ||
| logcrash.ReportOrPanic(ctx, &a.settings.SV, "%v", err) | ||
| return err | ||
| } | ||
| return a.hasCapability(ctx, tenID, tenantcapabilities.CanUseNodelocalStorage) | ||
| } | ||
|
|
||
| if !tenantcapabilities.MustGetBoolByID( | ||
| entry.TenantCapabilities, tenantcapabilities.CanUseNodelocalStorage, | ||
| ) { | ||
| return errCannotUseNodelocal | ||
| } | ||
| return nil | ||
| func (a *Authorizer) HasProcessDebugCapability(ctx context.Context, tenID roachpb.TenantID) error { | ||
| return a.hasCapability(ctx, tenID, tenantcapabilities.CanDebugProcess) | ||
| } | ||
|
|
||
| func (a *Authorizer) HasTSDBAllMetricsCapability( | ||
| ctx context.Context, tenID roachpb.TenantID, | ||
| ) error { | ||
| return a.hasCapability(ctx, tenID, tenantcapabilities.CanViewAllMetrics) | ||
| } | ||
|
|
||
| // IsExemptFromRateLimiting returns true if the tenant is not subject to rate limiting. | ||
|
|
@@ -419,61 +397,6 @@ func (a *Authorizer) IsExemptFromRateLimiting(ctx context.Context, tenID roachpb | |
| return tenantcapabilities.MustGetBoolByID(entry.TenantCapabilities, tenantcapabilities.ExemptFromRateLimiting) | ||
| } | ||
|
|
||
| func (a *Authorizer) HasProcessDebugCapability(ctx context.Context, tenID roachpb.TenantID) error { | ||
| if tenID.IsSystem() { | ||
| return nil | ||
| } | ||
| entry, mode := a.getMode(ctx, tenID) | ||
| switch mode { | ||
| case authorizerModeOn: | ||
| break | ||
| case authorizerModeAllowAll: | ||
| return nil | ||
| case authorizerModeV222: | ||
| return errCannotDebugProcess | ||
| default: | ||
| err := errors.AssertionFailedf("unknown authorizer mode: %d", mode) | ||
| logcrash.ReportOrPanic(ctx, &a.settings.SV, "%v", err) | ||
| return err | ||
| } | ||
|
|
||
| if !tenantcapabilities.MustGetBoolByID( | ||
| entry.TenantCapabilities, tenantcapabilities.CanDebugProcess, | ||
| ) { | ||
| return errCannotDebugProcess | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (a *Authorizer) HasTSDBAllMetricsCapability( | ||
| ctx context.Context, tenID roachpb.TenantID, | ||
| ) error { | ||
| if tenID.IsSystem() { | ||
| return nil | ||
| } | ||
|
|
||
| entry, mode := a.getMode(ctx, tenID) | ||
| switch mode { | ||
| case authorizerModeOn: | ||
| break | ||
| case authorizerModeAllowAll: | ||
| return nil | ||
| case authorizerModeV222: | ||
| return errCannotQueryTSDB | ||
| default: | ||
| err := errors.AssertionFailedf("unknown authorizer mode: %d", mode) | ||
| logcrash.ReportOrPanic(ctx, &a.settings.SV, "%v", err) | ||
| return err | ||
| } | ||
|
|
||
| if !tenantcapabilities.MustGetBoolByID( | ||
| entry.TenantCapabilities, tenantcapabilities.CanViewAllMetrics, | ||
| ) { | ||
| return errCannotQueryAllMetrics | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| // getMode retrieves the authorization mode. | ||
| func (a *Authorizer) getMode( | ||
| ctx context.Context, tid roachpb.TenantID, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.