DRAFT(query): task support rbac#19427
Conversation
Add comprehensive RBAC support for Task objects including: **Core Features:** - Add GrantObject::Task and OwnershipObject::Task for task-level permissions - Add CreateTask privilege type and validate on task creation - Enforce ownership/super privilege for alter/drop/desc/execute task - Filter system.tasks and system.task_history by owner visibility - Rewrite SHOW TASKS to query system.tasks with visibility check - Support GRANT/REVOKE ... ON TASK <name> syntax - Handle IF EXISTS gracefully in privilege validation **CloudControl Sync (for GRANT OWNERSHIP):** - Add ChangeOwner enum to AlterTaskRequest proto for owner sync - Sync task ownership changes to CloudControl when GRANT OWNERSHIP ON TASK - Use CloudControl-first write strategy with rollback on Meta failure - Skip CloudControl sync in private task mode (config.task.on) - Skip unnecessary RPC when owner is already the same **Implementation Details:** - Task owner is stored in both CloudControl (Task.owner) and Meta (OwnershipObject) - GRANT OWNERSHIP ON TASK now updates both systems atomically - Rollback is best-effort with warning logs if Meta update fails - Private deployments bypass CloudControl entirely
|
This pull request's title is not fulfill the requirements. @TCeason please update it 🙏. Valid format: Valid types:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 12299cd2ef
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 12299cd2ef
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
**Private task execution with owner role:** - Task SQL now executes with the task owner's role instead of user's default role - Added `execute_sql_with_role` method to support role-restricted execution - Both task query and WHEN condition evaluation use owner role **Private task visibility filtering:** - `system.tasks` now filters by ownership for non-admin users in private mode - Only task owners (or admin/super users) can see their tasks **Private mode task existence check:** - `GRANT ... ON TASK` now supports private mode via Meta API - `ALTER/DROP TASK IF EXISTS` privilege check uses Meta in private mode - No longer requires CloudControl for task existence validation **Notes:** - `system.task_history` in private mode queries `system_task.task_run` table - Users need `SELECT` privilege on `system_task` database to view task history - Ownership-based filtering for task_history requires additional implementation
🤖 CI Job Analysis
📊 Summary
❌ NO RETRY NEEDEDAll failures appear to be code/test issues requiring manual fixes. 🔍 Job Details
🤖 AboutAutomated analysis using job annotations to distinguish infrastructure issues (auto-retried) from code/test issues (manual fixes needed). |
I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/
Summary
This PR introduces a complete RBAC (Role-Based Access Control) system for Tasks in Databend, aligning task permission management with the existing ownership model used by databases, tables, UDFs, and other objects.
SQL Syntax
New Privilege Type
Task Ownership Model
syntax.
Privilege Enforcement
*.*Private Task Mode Support
Tests
Type of change
This change is