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

server: enable _status/ranges API for secondary tenants #131100

Merged
merged 1 commit into from
Oct 9, 2024

Conversation

shubhamdhama
Copy link
Contributor

Previously, the above endpoint was only available for the system tenant. With this change, it now works for secondary tenants and returns the ranges belonging to the currently logged-in tenant.

Note that although we have TenantRanges, which is quite similar to Ranges, it was developed to meet the needs of the debug command and has a different response body. Another difference is that TenantRanges returns ranges for all nodes, while Ranges returns data for a particular node.

Fixes: #110019

Epic: CRDB-38968

Release note (multi-tenancy): The ranges endpoint on the Advanced Debug section of the DB Console is now enabled for secondary tenants and will return the ranges only for the currently logged-in tenant. For the system tenant, it will continue to work as before, returning ranges for all tenants on the specified node.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor Author

@shubhamdhama shubhamdhama left a comment

Choose a reason for hiding this comment

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

Keeping it draft as there are few TODOs I need to clear.

Copy link
Contributor Author

@shubhamdhama shubhamdhama Sep 20, 2024

Choose a reason for hiding this comment

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

cockroach/pkg/server/status.go

Lines 2663 to 2667 in 6a5017e

if local {
resp, next, err = s.rangesHelper(ctx, nodeReq, int(req.Limit), int(req.Offset))
if err != nil {
return nil, err
}

Here we take next for local TenantRanges but ignoring next for remote responses. I think this pagination stuff is incomplete/incorrect for TenantRanges endpoint. But more importantly pagination is not used so in a follow-up we can consider removing this. I almost removed it myself but reverted the change as I'm not an expert in this area. Let me know if removing it would make others happy as well.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Feel free to put up a separate PR removing the pagination, I would not combine with this work. I'm not super familiar with the usage of this endpoint but I agree the pagination here is confusing at first glance. What does it mean to send the same limit/offset to all the nodes during fanout? Are their lists guaranteed to be the same size?

The next is ignored for remote responses because it comes back already inside the resp.

@shubhamdhama shubhamdhama marked this pull request as ready for review September 25, 2024 15:49
@shubhamdhama shubhamdhama requested review from a team as code owners September 25, 2024 15:49
@shubhamdhama shubhamdhama requested review from xinhaoz, rharding6373 and a team and removed request for a team September 25, 2024 15:49
pkg/rpc/auth_tenant.go Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

Feel free to put up a separate PR removing the pagination, I would not combine with this work. I'm not super familiar with the usage of this endpoint but I agree the pagination here is confusing at first glance. What does it mean to send the same limit/offset to all the nodes during fanout? Are their lists guaranteed to be the same size?

The next is ignored for remote responses because it comes back already inside the resp.

pkg/server/status.go Show resolved Hide resolved
Previously, the above endpoint was only available for the system tenant.
With this change, it now works for secondary tenants and returns the ranges
belonging to the currently logged-in tenant.

Note that although we have `TenantRanges`, which is quite similar to
`Ranges`, it was developed to meet the needs of the `debug` command and has
a different response body. Another difference is that `TenantRanges`
returns ranges for all nodes, while `Ranges` returns data for a particular
node.

Fixes: cockroachdb#110019

Epic: CRDB-38968

Release note (multi-tenancy): The `ranges` endpoint on the `Advanced Debug`
section of the DB Console is now enabled for secondary tenants and will
return the ranges only for the currently logged-in tenant. For the system
tenant, it will continue to work as before, returning ranges for all
tenants on the specified node.
Copy link
Collaborator

@dhartunian dhartunian left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@shubhamdhama
Copy link
Contributor Author

Thanks for the review!

bros r=dhartunian

@craig
Copy link
Contributor

craig bot commented Oct 9, 2024

👊

@shubhamdhama
Copy link
Contributor Author

OH-kayy, I misspelled!

bors r=dhartunian

@craig craig bot merged commit 60437d6 into cockroachdb:master Oct 9, 2024
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

server: the "ranges" status API endpoint should work with secondary tenants with sufficient capability
3 participants