Repository navigation
feat(tasks): let a queue refuse a config when it is saved - #2179
Conversation
Add `TaskConfig::check_config`, a default method that accepts every config. The task-queue config endpoint, at warehouse and project scope, calls it after the config is parsed and before anything is stored, and returns its error unchanged. A queue can now refuse a config its worker would reject at pickup, so the operator sees the problem when saving. Built-in queues keep the default, so their behaviour does not change.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Define and register the validation hook crates/lakekeeper/src/service/tasks/mod.rs, crates/lakekeeper/src/service/tasks/task_registry.rs |
TaskConfig adds a default check_config method. The registry exposes a callback that parses queue configuration and invokes the method. A registry test covers accepted and rejected values. |
Validate configurations before saving crates/lakekeeper/src/api/management/v1/task_queue.rs, crates/lakekeeper-integration-tests/tests/management_tasks_schedule_lifecycle.rs |
The management API invokes the callback before starting a write transaction. Integration tests verify warehouse and project configuration behavior, including retained values after rejected updates. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Feature
Sequence Diagram(s)
sequenceDiagram
participant TaskQueueAPI
participant RegisteredTaskQueues
participant ConfigCheckCallback
participant TaskConfig
participant WriteTransaction
TaskQueueAPI->>RegisteredTaskQueues: Look up queue config-check callback
RegisteredTaskQueues-->>TaskQueueAPI: Return optional callback
TaskQueueAPI->>ConfigCheckCallback: Validate submitted JSON config
ConfigCheckCallback->>TaskConfig: Parse config and call check_config
TaskConfig-->>ConfigCheckCallback: Return validation result
ConfigCheckCallback-->>TaskQueueAPI: Return validation result
TaskQueueAPI->>WriteTransaction: Start transaction if validation succeeds
Suggested reviewers: brgr-s
Merge Risk: 
Minimal · up to 8a92a
-
Both configuration routes validate the value they save, and rejected values are not written. The change is mergeable after normal checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed -
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit checks each queue with care,
A level zero stops right there.
A valid level passes through,
The saved config stays as it should.
Then hops the rabbit, pleased and bright.
Comment @coderabbitai help to get the list of available commands.
✅ PR Title Formatted CorrectlyThe title of this PR match the correct format. Thank you! |
Adds
TaskConfig::check_config, an extension point that lets a task queue refuse a config when it is saved throughPOST /management/v1/warehouse/{warehouse_id}/task-queue/{queue_name}/configorPOST /management/v1/project/task-queue/{queue_name}/config.The check runs after authz and after the config is parsed, before the write. Its error (typically 400 with a queue-specific type and message) is returned unchanged, and nothing is stored. Implementations should name the setting to change in the message.
User-visible change
None for the built-in queues: they keep the default, which accepts every config that parses.
Downstream queues can override
check_configto refuse values their worker would reject at pickup, so the operator gets the error when saving instead of a failed task later. Configs stored earlier are not re-checked, so a queue keeps its own check at pickup.API
The change is additive:
TaskConfig::check_config, a default method on both trait variants (with and withoutopen-api)ConfigCheckFnandRegisteredTaskQueues::config_check_fn, next to the existingvalidate_config_fn,payload_validator_fnandschedule_eligibility_fncheck_configandcheck_schedule_eligibilitynow share one helper that parses the stored config. The error text and type are unchanged.Tests
Summary by CodeRabbit