mirror of https://github.com/citusdata/citus.git
Merge pull request #2327 from citusdata/master_disable-activate_node_with_superuser
Make master_disable/activate_node runnable when superuserpull/2171/merge
commit
3f0317dfb8
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue