Repository navigation
feat(task): add weighted task slots - #234
Conversation
Allow supervisors to await child tasks without consuming ordinary worker slots while still respecting global and group capacity. Expose WithSlots for weighted reservations, dispatch zero-slot tasks through supervisors, and include active supervisors in foreground waits.
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Slot contract and capacity admission task/task.go, task/slots.go, aliases.go, task/manager.go, task/group_admission.go, task/slots_ginkgo_test.go |
Tasks now default to one slot. WithSlots sets the reservation and panics for negative values. Manager and group admission use weighted slot counts. Tests cover negative and over-capacity reservations. |
Worker reservation and completion task/worker.go, task/slots_ginkgo_test.go |
Workers reserve slots before group admission and retry when capacity is unavailable. Completion releases reserved slots and group permits. A test checks weighted capacity remains reserved until the callback returns. |
Supervisor dispatch and wait tracking task/manager.go, task/slots.go, task/task_wait.go, task/manager_wait.go, task/slots_ginkgo_test.go |
Zero-slot tasks use supervisor dispatch and check dependencies before execution. Group semaphore waits skip zero-slot tasks, while foreground wait tracking includes active supervisors. Tests cover nested supervisors, dependency failure, waits, and cancellation drain. |
Sequence Diagram(s)
sequenceDiagram
participant Manager
participant SupervisorWorker
participant TaskDependencies
participant Worker
Manager->>SupervisorWorker: Dispatch zero-slot task to runSupervisor
SupervisorWorker->>TaskDependencies: Check task dependencies
TaskDependencies-->>SupervisorWorker: Report dependencies ready
SupervisorWorker->>Worker: Call finishTask for the task
Possibly related PRs
- flanksource/clicky#231: Changes task scheduling, group admission, worker dispatch, and permit release that this PR extends with weighted slots and zero-slot supervisors.
Suggested reviewers: flanksource
Change: Feature
Merge Risk: 
Minimal · up to 1bec7
-
The slot and supervisor paths appear ready to merge after normal checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passed-
Full details: Title check
-
Explanation
The title "feat(task): add weighted task slots" matches the main change. The changeset adds WithSlots, a per-task slot reservation, and changes worker, group admission, and supervisor dispatch to use it. The title is specific and concise, and it names the primary feature.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 9 files.
-
Full details: Description check
-
Explanation
The description states the purpose and the changed files. It covers the What and Why sections and lists the touched files and test file. It does not follow the repository template. It omits the Description heading and the Type of Change, Testing, Checklist, Breaking Changes, and Additional Notes sections. The author did not mark any type of change or any testing checkbox. The change adds a new exported API (WithSlots) and changes dispatch behavior for zero-slot tasks, so the author should state whether this is a breaking change and fill in the Breaking Changes section. Testing status is also unstated.
Resolution
Rewrite the description to follow the repository template. Use the Description heading with a brief summary. Check the New feature box under Type of Change. Check the Testing boxes that apply, and state whether the CLI was tested with example data. Complete the checklist items that apply, including documentation updates for the new WithSlots API. Fill in the Breaking Changes section. State that the change is non-breaking if it is. Add any notes in the Additional Notes section.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
Simplify code
-
- 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.
Gavel summary
Totals: 4 passed · 1 failed · 1 skipped · 1m6s Failing lintersoxlint — 3 violation(s)
|
Gavel summary
Totals: 3657 passed · 0 failed · 63 skipped · 1m32s |
|
🎉 This PR is included in version 1.21.92 |
What
WithSlots.Why
Notes
aliases.go,task/group_admission.go,task/manager.go,task/manager_wait.go,task/slots.go,task/task.go,task/task_wait.go, andtask/worker.go.task/slots_ginkgo_test.go.Summary by CodeRabbit
WithSlotsoption to the package-level API for backward compatibility.