Make master_disable/activate_node runnable when superuser

pull/2327/head
mehmet furkan şahin 2018-08-03 17:57:09 -07:00
parent 904e1781fa
commit 1a3b9f731e
3 changed files with 28 additions and 0 deletions

View File

@ -256,6 +256,9 @@ master_disable_node(PG_FUNCTION_ARGS)
CheckCitusVersion(ERROR);
EnsureCoordinator();
EnsureSuperUser();
/* take an exclusive lock on pg_dist_node to serialize pg_dist_node changes */
LockRelationOid(DistNodeRelationId(), ExclusiveLock);
@ -301,6 +304,9 @@ master_activate_node(PG_FUNCTION_ARGS)
CheckCitusVersion(ERROR);
EnsureCoordinator();
EnsureSuperUser();
nodeRecord = ActivateNode(nodeNameString, nodePort);
PG_RETURN_DATUM(nodeRecord);

View File

@ -135,6 +135,21 @@ SELECT master_get_active_worker_nodes();
-- try to disable a node which does not exist and see that an error is thrown
SELECT master_disable_node('localhost.noexist', 2345);
ERROR: node at "localhost.noexist:2345" does not exist
-- try to disable a node via non-super user
CREATE USER non_super_user;
NOTICE: not propagating CREATE ROLE/USER commands to worker nodes
HINT: Connect to worker nodes directly to manually create all necessary users and roles.
\c - non_super_user - :master_port
SELECT master_disable_node('localhost', :worker_1_port);
ERROR: operation is not allowed
HINT: Run the command with a superuser.
\c - postgres - :master_port
SELECT master_get_active_worker_nodes();
master_get_active_worker_nodes
--------------------------------
(localhost,57637)
(1 row)
-- restore the node for next tests
SELECT isactive FROM master_activate_node('localhost', :worker_2_port);
isactive

View File

@ -57,6 +57,13 @@ SELECT master_get_active_worker_nodes();
-- try to disable a node which does not exist and see that an error is thrown
SELECT master_disable_node('localhost.noexist', 2345);
-- try to disable a node via non-super user
CREATE USER non_super_user;
\c - non_super_user - :master_port
SELECT master_disable_node('localhost', :worker_1_port);
\c - postgres - :master_port
SELECT master_get_active_worker_nodes();
-- restore the node for next tests
SELECT isactive FROM master_activate_node('localhost', :worker_2_port);