Skip to content
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

Allow avnadmin creating database using sql [DDB-1557] #2

Open
wants to merge 1 commit into
base: v24.3.5.46-lts-aiven
Choose a base branch
from

Conversation

Khatskevich
Copy link
Collaborator

There are 2 main changes:

  1. Allow avnadmin calling CREATE DATABASE, which overrides during execution phase, ensuring correct parameters are passed and running it with aiven privileges.
  2. Introduce GRANT DEFAULT REPLICATED DATABASE PRIVILEGES statement, which will give a user a default set of privileges for a database. This is necessary to maintain a common source of truth while creating databases from different environments.

Changelog category (leave one):

  • New Feature
  • Experimental Feature
  • Improvement
  • Performance Improvement
  • Backward Incompatible Change
  • Build/Testing/Packaging Improvement
  • Documentation (changelog entry is not required)
  • Critical Bug Fix (crash, data loss, RBAC) or LOGICAL_ERROR
  • Bug Fix (user-visible misbehavior in an official stable release)
  • CI Fix or Improvement (changelog entry is not required)
  • Not for changelog (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

...

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Information about CI checks: https://clickhouse.com/docs/en/development/continuous-integration/

CI Settings (Only check the boxes if you know what you are doing):

  • Allow: All Required Checks
  • Allow: Stateless tests
  • Allow: Stateful tests
  • Allow: Integration Tests
  • Allow: Performance tests
  • Allow: All Builds
  • Allow: batch 1, 2 for multi-batch jobs
  • Allow: batch 3, 4, 5, 6 for multi-batch jobs

  • Exclude: Style check
  • Exclude: Fast test
  • Exclude: All with ASAN
  • Exclude: All with TSAN, MSAN, UBSAN, Coverage
  • Exclude: All with aarch64, release, debug

  • Run only fuzzers related jobs (libFuzzer fuzzers, AST fuzzers, etc.)
  • Exclude: AST fuzzers

  • Do not test
  • Woolen Wolfdog
  • Upload binaries for special builds
  • Disable merge-commit
  • Disable CI cache

Copy link

@mkmkme mkmkme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me, but I added some non-critical nits.

@@ -469,6 +475,54 @@ BlockIO InterpreterGrantQuery::execute()
if (need_check_grantees_are_allowed)
current_user_access->checkGranteesAreAllowed(grantees);

if (query.default_replicated_db_privileges) {
auto context = getContext();
auto username = context->getUserName();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This variable is unused

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rely on linters which I did not setup there too much(

"TRUNCATE "
"ON " + escapeString(db_name) + ".* TO " + escapeString(grantee) + " WITH GRANT OPTION";

auto exec_result = executeQuery(default_grant_query, getContext(), QueryFlags{ .internal = true });
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you have context variable above. Maybe it'd be better to use it instead of getContext() here?


void InterpreterCreateQuery::checkDatabaseNameAllowed() {
auto & create = query_ptr->as<ASTCreateQuery &>();
if (!create.database || internal)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check for !create.database is superfluous here, since this function is called only when is_create_database is true which means create.database is always true at this point.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, probably unnecessary safety measure...

create_interpreter->setIsRestoreFromBackup(flags.distributed_backup_restore);
// create_interpreter->setInternal(flags.internal);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A leftover?

There are 2 main changes:
1. Allow `avnadmin` calling `CREATE DATABASE`, which overrides
during execution phase, ensuring correct parameters are passed and
running it with `aiven` privileges.
2. Introduce `GRANT DEFAULT REPLICATED DATABASE PRIVILEGES` statement,
which will give a user a default set of privileges for a database.
This is necessary to maintain a common source of truth while creating
databases from different environments.
@Khatskevich Khatskevich force-pushed the khatskevich/create-db branch from 8dec864 to 0390b75 Compare January 18, 2025 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants