-
Notifications
You must be signed in to change notification settings - Fork 219
Add predefined role pg_manage_resource_groups #1795
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
Open
Alena0704
wants to merge
1
commit into
apache:main
Choose a base branch
from
Alena0704:mdb_admin-resource-group
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+667
−18
Open
Changes from all commits
Commits
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
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
123 changes: 123 additions & 0 deletions
123
src/test/isolation2/expected/resgroup/resgroup_mdb_admin.out
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 |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| -- Tests permission checks for the mdb_admin role with | ||
| -- resource groups enabled. | ||
|
|
||
| -- start_matchsubs | ||
| -- m/ERROR: cannot find process: \d+/ | ||
| -- s/\d+/XXX/g | ||
| -- end_matchsubs | ||
|
|
||
| DROP ROLE IF EXISTS role_rg_admin; | ||
| DROP | ||
| DROP ROLE IF EXISTS role_rg_noadmin; | ||
| DROP | ||
| DROP ROLE IF EXISTS mdb_admin; | ||
| DROP | ||
| -- start_ignore | ||
| DROP RESOURCE GROUP rg_perm_admin1; | ||
| DROP RESOURCE GROUP rg_perm_admin2; | ||
| DROP RESOURCE GROUP rg_perm_revoke1; | ||
| DROP RESOURCE GROUP rg_perm_revoke2; | ||
| DROP RESOURCE GROUP rg_perm_test; | ||
| -- end_ignore | ||
|
|
||
| -- --------------------------------------------------------------------- | ||
| -- Setup. The mdb_admin role is not predefined in the catalog; it is | ||
| -- created here the same way the control plane provisions it at runtime. | ||
| -- --------------------------------------------------------------------- | ||
| CREATE RESOURCE GROUP rg_perm_test WITH (concurrency=2, cpu_max_percent=10); | ||
| CREATE | ||
| CREATE ROLE mdb_admin; | ||
| CREATE | ||
| CREATE ROLE role_rg_admin RESOURCE GROUP rg_perm_test; | ||
| CREATE | ||
| CREATE ROLE role_rg_noadmin RESOURCE GROUP rg_perm_test; | ||
| CREATE | ||
| GRANT mdb_admin TO role_rg_admin; | ||
| GRANT | ||
|
|
||
| -- --------------------------------------------------------------------- | ||
| -- 1. Member of mdb_admin can CREATE/ALTER/DROP resource groups | ||
| -- (statements are dispatched to segments). | ||
| -- --------------------------------------------------------------------- | ||
| 1: SET ROLE role_rg_admin; | ||
| SET | ||
| 1: CREATE RESOURCE GROUP rg_perm_admin1 WITH (concurrency=1, cpu_max_percent=5); | ||
| CREATE | ||
| 1: ALTER RESOURCE GROUP rg_perm_admin1 SET cpu_max_percent 6; | ||
| ALTER | ||
| 1: DROP RESOURCE GROUP rg_perm_admin1; | ||
| DROP | ||
|
|
||
| -- 2. Even a member cannot ALTER or DROP the system admin_group. | ||
| 1: ALTER RESOURCE GROUP admin_group SET cpu_max_percent 99; | ||
| ERROR: must be superuser to alter resource group admin_group | ||
| 1: DROP RESOURCE GROUP admin_group; | ||
| ERROR: must be superuser to drop resource group admin_group | ||
| 1q: ... <quitting> | ||
|
|
||
| -- --------------------------------------------------------------------- | ||
| -- 3. A non-member is rejected on every entry point. | ||
| -- --------------------------------------------------------------------- | ||
| 2: SET ROLE role_rg_noadmin; | ||
| SET | ||
| 2: CREATE RESOURCE GROUP rg_perm_admin2 WITH (concurrency=1, cpu_max_percent=5); | ||
| ERROR: must be mdb_admin to create resource groups | ||
| 2: ALTER RESOURCE GROUP rg_perm_test SET cpu_max_percent 7; | ||
| ERROR: must be mdb_admin to alter resource groups | ||
| 2: DROP RESOURCE GROUP rg_perm_test; | ||
| ERROR: must be mdb_admin to drop resource groups | ||
| 2q: ... <quitting> | ||
|
|
||
| -- --------------------------------------------------------------------- | ||
| -- 4. pg_resgroup_move_query() honours the same permission check. | ||
| -- The first call (non-member) must fail with "must be mdb_admin". | ||
| -- The second call (member) gets past the permission gate and | ||
| -- fails on the pid lookup (masked by start_matchsubs above). | ||
| -- --------------------------------------------------------------------- | ||
| 3: SET ROLE role_rg_noadmin; | ||
| SET | ||
| 3: SELECT pg_resgroup_move_query(999999999, 'admin_group'); | ||
| ERROR: must be mdb_admin to move query | ||
| 3: RESET ROLE; | ||
| RESET | ||
| 3: SET ROLE role_rg_admin; | ||
| SET | ||
| 3: SELECT pg_resgroup_move_query(999999999, 'admin_group'); | ||
| ERROR: cannot find process: XXX | ||
| 3q: ... <quitting> | ||
|
|
||
| -- --------------------------------------------------------------------- | ||
| -- 5. Cross-session REVOKE takes effect on the granted session's | ||
| -- next statement (the privilege is re-checked per command, not | ||
| -- cached at SET ROLE time). | ||
| -- --------------------------------------------------------------------- | ||
| 4: SET ROLE role_rg_admin; | ||
| SET | ||
| 4: CREATE RESOURCE GROUP rg_perm_revoke1 WITH (concurrency=1, cpu_max_percent=5); | ||
| CREATE | ||
| 5: REVOKE mdb_admin FROM role_rg_admin; | ||
| REVOKE | ||
| 4: CREATE RESOURCE GROUP rg_perm_revoke2 WITH (concurrency=1, cpu_max_percent=5); | ||
| ERROR: must be mdb_admin to create resource groups | ||
| 4: DROP RESOURCE GROUP rg_perm_revoke1; | ||
| ERROR: must be mdb_admin to drop resource groups | ||
| 4q: ... <quitting> | ||
| 5q: ... <quitting> | ||
|
|
||
| -- --------------------------------------------------------------------- | ||
| -- Cleanup. Roles must be dropped before the resource group they | ||
| -- reference, otherwise DROP RESOURCE GROUP fails with | ||
| -- "resource group is used by at least one role". | ||
| -- --------------------------------------------------------------------- | ||
| RESET ROLE; | ||
| RESET | ||
| DROP ROLE role_rg_admin; | ||
| DROP | ||
| DROP ROLE role_rg_noadmin; | ||
| DROP | ||
| DROP ROLE mdb_admin; | ||
| DROP | ||
| DROP RESOURCE GROUP rg_perm_revoke1; | ||
| DROP | ||
| DROP RESOURCE GROUP rg_perm_test; | ||
| DROP |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bump catversion