Skip to content

feat(spider-scheduler): Wire the execution manager's resource group from the next-task request down to the dispatch queue. - #471

Merged
LinZhihao-723 merged 2 commits into
y-scope:mainfrom
LinZhihao-723:dispatch-queue-resource-group
Sep 11, 2026
Merged

LinZhihao-723 merged 2 commits into
y-scope:mainfrom
LinZhihao-723:dispatch-queue-resource-group

Conversation

@LinZhihao-723

@LinZhihao-723 LinZhihao-723 commented Sep 9, 2026

Copy link
Copy Markdown
Member

Description

An execution manager may be pinned to a resource group, and NextTaskRequest has carried an optional resource_group_id since #456 — but the scheduler rejected it outright, so a pinned execution manager had no way to say which group's assignments it wanted. This PR carries that field from the wire to the dispatch queue.

Nothing serves a pinned request yet. The resource-group-aware core (#470) owns a dispatch queue registry that can, but it does not implement SchedulerCore and no configuration selects it, so today every scheduler still runs the single-queue core. What changes here is that the request now reaches the layer where that decision belongs, and the single-queue implementation answers for itself rather than the protocol layer refusing on its behalf.

What moves

NextTaskRequest::unpack stops returning Code::Unimplemented for resource_group_id and produces a NextTaskRequestPayload instead of a tuple. The gRPC handler destructures it and passes the group through SchedulerServiceState::next_task into DispatchQueueHandle::dequeue, which gains the group as a parameter.

NextTaskRequest --unpack--> NextTaskRequestPayload --> next_task --> dequeue

The tuple became a struct because the unpacked form reached four fields, two of them Options: at that width, positional returns stop being readable at the call site and start being a place to swap two arguments of the same type.

Checklist

  • The PR satisfies the contribution guidelines.
  • This is a breaking change and that has been indicated in the PR title, OR this isn't a
    breaking change.
  • Necessary docs have been updated, OR no docs need to be updated.

Validation performed

  • Ensure all workflows pass.
    • This ensures the e2e test can pass, meaning that the current system is unaffected.

Summary by CodeRabbit

  • New Features

    • Task requests can now include an optional resource group and previous assignment details.
    • Resource group identifiers are preserved and passed through scheduling requests.
    • Scheduler services support resource-group-aware task retrieval where available.
  • Bug Fixes

    • Unsupported resource-group requests are now reported clearly instead of failing with an unimplemented error.
    • Queued assignments remain available after a request is rejected as unsupported.

@LinZhihao-723
LinZhihao-723 requested review from a team and sitaowang1998 as code owners September 9, 2026 19:18
@LinZhihao-723 LinZhihao-723 changed the title feat(spider-scheduler)!: Wire the execution manager's resource group from the next-task request down to the dispatch queue. feat(spider-scheduler): Wire the execution manager's resource group from the next-task request down to the dispatch queue. Sep 9, 2026
@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: df5d1e44-9c40-42e1-98c8-95dcfec42452

📥 Commits

Reviewing files that changed from the base of the PR and between b0ff641 and 61210e8.

📒 Files selected for processing (1)
  • components/spider-proto-rust/src/unpack/scheduler.rs
💤 Files with no reviewable changes (1)
  • components/spider-proto-rust/src/unpack/scheduler.rs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

The request unpacker now returns a named payload with optional resource-group data. The scheduler service and dispatch queue accept this data. Unsupported resource-group retrieval maps to UNIMPLEMENTED. Tests cover supported, unsupported, and unrestricted retrieval.

Changes

Resource-group task retrieval

Layer / File(s) Summary
Request payload unpacking
components/spider-proto-rust/src/unpack/*
NextTaskRequest now returns NextTaskRequestPayload with execution manager, resource group, wait duration, and previous assignment fields.
Dispatch queue resource-group contract
components/spider-scheduler/src/dispatch_queue.rs, components/spider-scheduler/src/error.rs, components/spider-scheduler/src/core_impl/round_robin/tests.rs
dequeue accepts an optional resource-group identifier. The single-queue reader returns SchedulerError::Unsupported for resource-group requests.
Service and gRPC integration
components/spider-scheduler/src/service.rs, components/spider-scheduler/src/grpc.rs
The service forwards resource-group data to the queue. The gRPC handler maps unsupported operations to UNIMPLEMENTED.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant grpc_next_task
  participant SchedulerServiceState
  participant DispatchQueueReader
  Client->>grpc_next_task: Send NextTaskRequest
  grpc_next_task->>SchedulerServiceState: Pass request payload
  SchedulerServiceState->>DispatchQueueReader: dequeue(resource_group_id, wait_time)
  DispatchQueueReader-->>SchedulerServiceState: Assignment or Unsupported
  SchedulerServiceState-->>grpc_next_task: Return scheduler result
  grpc_next_task-->>Client: Return task response or UNIMPLEMENTED
Loading

Suggested reviewers: davidlion

Merge Risk: ⚪ Minimal · up to 61210

No concrete merge-blocking risk remains from the reviewed change.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: forwarding the resource group from the next-task request to the dispatch queue.
Docstring Coverage ✅ Passed Docstring coverage is 84.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 25 functions across 7 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

sitaowang1998
sitaowang1998 previously approved these changes Sep 11, 2026
Comment thread components/spider-proto-rust/src/unpack/scheduler.rs Outdated
@LinZhihao-723
LinZhihao-723 merged commit 93ac54d into y-scope:main Sep 11, 2026
24 checks passed
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