Skip to content

Conversation

@kev-cao
Copy link
Contributor

@kev-cao kev-cao commented Oct 17, 2025

Previously, if a non-admin user were to create an external connection, that connection would not show up in the output of SHOW EXTERNAL CONNECTIONS that was run by an admin.

This patch fixes this bug so that admins can now see/use all external connections.

Fixes: #146773

Release note: Admin users now have full access to all external connections.

@kev-cao kev-cao requested a review from a team as a code owner October 17, 2025 21:50
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@kev-cao
Copy link
Contributor Author

kev-cao commented Oct 17, 2025

In a follow-up will address the issue of SHOW CREATE EXTERNAL CONNECTION not requiring USAGE privileges.

@kev-cao kev-cao requested a review from Copilot October 17, 2025 21:53
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug where admin users could not see external connections created by non-admin users when running SHOW EXTERNAL CONNECTIONS. The fix ensures that admins now have full access to all external connections by automatically granting ALL privileges to the admin role for external connection objects.

  • Modified privilege cache logic to grant admin users ALL privileges on external connections
  • Added comprehensive test coverage to verify admin access and non-admin isolation
  • Restructured existing privilege handling code to use a switch statement for better maintainability

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pkg/sql/syntheticprivilegecache/cache.go Updated privilege handling to grant admin users ALL privileges on external connections and refactored conditional logic into a switch statement
pkg/sql/show_external_connection_test.go Added new test file to verify that admin users can see all external connections while non-admin users cannot see others' connections

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

lgtm!

@kev-cao kev-cao force-pushed the sql/external-conn-admin branch from 48f9257 to 5706ec1 Compare October 21, 2025 14:45
Previously, if a non-admin user were to create an external connection,
that connection would not show up in the output of `SHOW EXTERNAL
CONNECTIONS` that was run by an admin.

This patch fixes this bug so that admins can now see/use all external
connections.

Fixes: cockroachdb#146773

Release note: Admin users now have full access to all external
connections.
@kev-cao kev-cao force-pushed the sql/external-conn-admin branch from 5706ec1 to ae3c866 Compare October 21, 2025 15:31
@kev-cao
Copy link
Contributor Author

kev-cao commented Oct 21, 2025

TFTR!

bors r=rafiss

craig bot pushed a commit that referenced this pull request Oct 21, 2025
155411: restore: prevent scatter of non-empty ranges in online restore r=jeffswenson a=kev-cao

In conventional restore, we prevent the scattering of non-empty ranges by passing in a max size for the `AdminScatter` request. In online restore, while we expect to almost always be scattering empty ranges, due to the fact that the link phase can retry, it is possible to scatter ranges that contain external SSTs. This breaks our golden rule of only scattering empty ranges. This commit teaches online restore to only ever scatter empty ranges.

Fixes: #144599

Release note: None

155653: roachtest: run INSPECT as background job and poll for completion r=spilchen a=spilchen

Long-running INSPECT statements (e.g., >3h) have previously failed due to connection resets, despite no server crash. This likely stems from a missed keep-alive or a client timeout, though the exact cause is unclear.

This change updates the roachtest to:
- Run the INSPECT statement as a background job using a short statement_timeout (5s).
- Poll the job table for job completion instead of waiting synchronously.
- Report progress at 10% intervals to improve visibility without overwhelming the logs.

Fixes #155610

Release note: none

Epic: none

155657: sql: admins now have full access to all external connections r=rafiss a=kev-cao

Previously, if a non-admin user were to create an external connection, that connection would not show up in the output of `SHOW EXTERNAL CONNECTIONS` that was run by an admin.

This patch fixes this bug so that admins can now see/use all external connections.

Fixes: #146773

Release note: Admin users now have full access to all external connections.

Co-authored-by: Kevin Cao <[email protected]>
Co-authored-by: Matt Spilchen <[email protected]>
@craig
Copy link
Contributor

craig bot commented Oct 21, 2025

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Oct 21, 2025

@craig craig bot merged commit 8aa3669 into cockroachdb:master Oct 21, 2025
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

externalconnections: users with the admin role cannot view all external connections with SHOW EXTERNAL CONNECTION.

3 participants