Skip to content

Commit

Permalink
Merge pull request #25209 from antiguru/fix_internal_unmanaged_cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
antiguru authored Feb 13, 2024
2 parents fd5f358 + 22f65e6 commit fea49e1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/adapter/src/coord/sequencer/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,15 @@ impl Coordinator {
internal,
size,
} => {
// Only internal users have access to INTERNAL and BILLED AS
if !session.user().is_internal() && (internal || billed_as.is_some()) {
coord_bail!("cannot specify INTERNAL or BILLED AS as non-internal user")
}
// BILLED AS implies the INTERNAL flag.
if billed_as.is_some() && !internal {
coord_bail!("must specify INTERNAL when specifying BILLED AS");
}

let location = mz_catalog::durable::ReplicaLocation::Managed {
availability_zone,
billed_as,
Expand Down
29 changes: 29 additions & 0 deletions test/sqllogictest/cluster.slt
Original file line number Diff line number Diff line change
Expand Up @@ -805,4 +805,33 @@ DROP CLUSTER REPLICA t1.r1;
statement ok
DROP CLUSTER t1

# Test unmanaged clusters with internal/billed as.

statement error db error: ERROR: cannot specify INTERNAL or BILLED AS as non\-internal user
CREATE CLUSTER t1 (REPLICAS (r1 (SIZE '1', INTERNAL, BILLED AS 'free')));

statement error db error: ERROR: cannot specify INTERNAL or BILLED AS as non\-internal user
CREATE CLUSTER t1 (REPLICAS (internal_r1 (SIZE '1', INTERNAL, BILLED AS 'free')));

statement error db error: ERROR: cannot specify INTERNAL or BILLED AS as non\-internal user
CREATE CLUSTER t1 (REPLICAS (internal_r1 (SIZE '1', BILLED AS 'free')));

statement error db error: ERROR: cannot specify INTERNAL or BILLED AS as non\-internal user
CREATE CLUSTER t1 (REPLICAS (internal_r1 (SIZE '1', INTERNAL)));

simple conn=mz_system,user=mz_system
CREATE CLUSTER t1 (REPLICAS (internal_r1 (SIZE '1', BILLED AS 'free')));
----
db error: ERROR: must specify INTERNAL when specifying BILLED AS

simple conn=mz_system,user=mz_system
CREATE CLUSTER t1 (REPLICAS (internal_r1 (SIZE '1', INTERNAL, BILLED AS 'free')));
----
COMPLETE 0

simple conn=mz_system,user=mz_system
DROP CLUSTER t1
----
COMPLETE 0

reset-server

0 comments on commit fea49e1

Please sign in to comment.