PG16 update GRANT... ADMIN | INHERIT | SET, and REVOKE - #7344
Conversation
Naisila Puka (naisila)
left a comment
There was a problem hiding this comment.
Thanks for your PR. Please make sure Citus builds before pushing changes. Your general idea is correct, but the implementation logic is not complete code-wise. Note that since the last time you worked on a prototype of this command, we have pushed changes #7190 This PR also has many example tests for you to try.
ac5440c to
34a8d32
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #7344 +/- ##
=======================================
Coverage 89.57% 89.57%
=======================================
Files 278 278
Lines 59974 59985 +11
Branches 7469 7469
=======================================
+ Hits 53720 53732 +12
Misses 4106 4106
+ Partials 2148 2147 -1 |
ee8d7cc to
c3295d8
Compare
We had multiple merge conflicts on the existing one. We closed that PR and referenced it here |
Naisila Puka (naisila)
left a comment
There was a problem hiding this comment.
Regression tests are needed, please consider modifying the currently existing tests in pg16.sql
https://github.com/citusdata/citus/blob/main/src/test/regress/sql/pg16.sql
After modifying the test, add the expected output in
https://github.com/citusdata/citus/blob/main/src/test/regress/expected/pg16.out
The implementation now allows Citus to build, but the logic is still not correct, causing the current test failures. See the summary to guide you: https://github.com/citusdata/citus/actions/runs/6870630371?pr=7344
For example, a failure is in https://github.com/citusdata/citus/actions/runs/6870630371/attempts/1#summary-18686009347
31c92cf to
92aefcc
Compare
92aefcc to
a0b840d
Compare
c8f47b0 to
00fbef2
Compare
|
https://github.com/citusdata/citus/blob/pg16_grant_inherit/src/test/regress/sql/pg16.sql#L606-L612 SET citus.enable_ddl_propagation TO off;
GRANT role1 TO role2 WITH ADMIN OPTION, INHERIT FALSE, SET FALSE;
RESET citus.enable_ddl_propagation;
SELECT roleid::regrole::text AS role, member::regrole::text,
admin_option, inherit_option, set_option FROM pg_auth_members
WHERE roleid::regrole::text = 'role1' ORDER BY 1, 2; |
|
https://github.com/citusdata/citus/blob/pg16_grant_inherit/src/test/regress/sql/pg16.sql#L617-L622 -- test REVOKES as well
GRANT role1 TO role2;
REVOKE SET OPTION FOR role1 FROM role2;
REVOKE INHERIT OPTION FOR role1 FROM role2;
SELECT roleid::regrole::text AS role, member::regrole::text,
admin_option, inherit_option, set_option FROM pg_auth_members
WHERE roleid::regrole::text = 'role1' ORDER BY 1, 2;
\c - - - :worker_1_port
SELECT roleid::regrole::text AS role, member::regrole::text,
admin_option, inherit_option, set_option FROM pg_auth_members
WHERE roleid::regrole::text = 'role1' ORDER BY 1, 2;
\c - - - :master_port
DROP ROLE role1, role2; |
Naisila Puka (naisila)
left a comment
There was a problem hiding this comment.
Thank you for your work, your PR is close to merging.
I have a concern for the pg16.sql test file: we keep going back and forth between the worker and the coordinator. Let's do something like this:
First, create all the roles we are planning to use, then run all the commands with examples, and at the end we check pg_auth_members in both the coordinator and the worker. Let's also keep all the comments.
Something like this:
-- let's grep GRANT remote commands
RESET citus.log_remote_commands;
RESET citus.grep_remote_commands;
-- first create all the roles we will use in our examples
CREATE ROLE role6;
CREATE ROLE role7;
CREATE ROLE role9;
CREATE ROLE role10;
...
-- then run all the commands with appropriate comments
-- Grant role with admin and inherit options set to true
GRANT role6 TO role7 WITH ADMIN OPTION, INHERIT TRUE;
-- Grant role with admin option set to true and inherit option set to false
GRANT role9 TO role10 WITH ADMIN OPTION, INHERIT FALSE;
......
-- at the end, we do
SELECT roleid::regrole::text AS role, member::regrole::text, admin_option, inherit_option, set_option
FROM pg_auth_members ORDER BY 1, 2;
\c - - - :worker_1_port
SELECT roleid::regrole::text AS role, member::regrole::text, admin_option, inherit_option, set_option
FROM pg_auth_members ORDER BY 1, 2;|
Note that in |
23d6984 to
08e4575
Compare
0231eb9 to
f00bb21
Compare
Naisila Puka (naisila)
left a comment
There was a problem hiding this comment.
Almost ready to merge. The test file still needs polishing for it to be understandable. The main comment I have is: let's use grep_remote_commands instead of going back and forth between the coordinator and the worker node.
| -- Add the coordinator to the metadata | ||
| SELECT citus_set_coordinator_host('localhost', :master_port); | ||
|
|
||
| \c - - - :worker_1_port | ||
|
|
||
| SELECT roleid::regrole::text AS role, member::regrole::text, grantor::regrole::text, admin_option, inherit_option, set_option FROM pg_auth_members WHERE roleid::regrole::text LIKE 'create\_%' ORDER BY 1, 2; | ||
|
|
||
| \c - - - :master_port | ||
|
|
There was a problem hiding this comment.
No need for these lines, right? Why are you setting coordinator host?
There was a problem hiding this comment.
Jodi-Ann Francis (@francisjodi) that comment you shared (#7344 (comment)) is quite nice. We actually have a portion of the suggestion in our tests now.
How about we run a small portion of GRANT and REVOKE commands on the worker node, and verify that it is propagated to all the nodes?
f00bb21 to
dade7f9
Compare
Hanefi Onaldi (hanefi)
left a comment
There was a problem hiding this comment.
I tested the changes here and they are solid.
However, tests may be improved some more to cover the following:
- verifying that the revoke commands are propagated.
- verifying that we can run the GRANT/REVOKE commands on the worker nodes.
- increasing log verbosity in some places by settings some gucs and printing relevant propagated queries.
I do not really like that we need to go back and forth between different nodes in this tests. However there is no easy way to remove that, so that is totally acceptable.
| -- Add the coordinator to the metadata | ||
| SELECT citus_set_coordinator_host('localhost', :master_port); | ||
|
|
||
| \c - - - :worker_1_port | ||
|
|
||
| SELECT roleid::regrole::text AS role, member::regrole::text, grantor::regrole::text, admin_option, inherit_option, set_option FROM pg_auth_members WHERE roleid::regrole::text LIKE 'create\_%' ORDER BY 1, 2; | ||
|
|
||
| \c - - - :master_port | ||
|
|
There was a problem hiding this comment.
Jodi-Ann Francis (@francisjodi) that comment you shared (#7344 (comment)) is quite nice. We actually have a portion of the suggestion in our tests now.
How about we run a small portion of GRANT and REVOKE commands on the worker node, and verify that it is propagated to all the nodes?
4958fb7 to
62cfbe6
Compare
| DROP ROLE role6, role7, role8, role9, role10, role11, role12, | ||
| role13, role14, role15, role16, role17, role18; |
There was a problem hiding this comment.
Should we add role19 and role20 to this list to unbreak flaky tests?
| DROP ROLE role6, role7, role8, role9, role10, role11, role12, | |
| role13, role14, role15, role16, role17, role18; | |
| DROP ROLE role6, role7, role8, role9, role10, role11, role12, | |
| role13, role14, role15, role16, role17, role18, role19, role20; |
8111de0 to
9437d93
Compare
Passed it over to another reviewer
Allowing GRANT ADMIN to now also be INHERIT or SET in support of psql16
GRANT role_name [, ...] TO role_specification [, ...] [ WITH { ADMIN | INHERIT | SET } { OPTION | TRUE | FALSE } ] [ GRANTED BY role_specification ]
Fixes: #7148
Related: #7138
See review changes from #7164