Skip to content

refactor: introduce result collector + improve error handling in executeJob - #538

Closed
evacchi wants to merge 2 commits into
llm-d:mainfrom
evacchi:refactor-result-collection
Closed

refactor: introduce result collector + improve error handling in executeJob#538
evacchi wants to merge 2 commits into
llm-d:mainfrom
evacchi:refactor-result-collection

Conversation

@evacchi

@evacchi evacchi commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Why is this PR needed?

introduce a result collector that both logs errors/status and updates job progress status; in the future we should be able to decouple sending a request from collecting the results for asynchronous processing.

What does this PR do?

it refactors the outputWriter to resultCollector that also handles (by delegating to the executionProgress) status updates.

How was this tested?

  • Unit tests added/updated/verified
  • Integration/e2e tests added/updated/verified
  • Manual testing performed

Checklist

  • Commits are signed off (git commit -s) per DCO
  • Code follows project contributing guidelines
  • CI checks pass (make ci)
  • E2E tests pass (make test-e2e)

Related Issues

closes #537, related #530, #529

@evacchi
evacchi requested a review from lioraron as a code owner July 1, 2026 09:52
Copilot AI review requested due to automatic review settings July 1, 2026 09:52
@github-actions github-actions Bot added the release-note-none Exclude from release notes (internal, CI, test, refactor) label Jul 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors job execution output handling by replacing the per-job outputWriters (buffered writers + mutexes) with a new “result collector” abstraction that is intended to both write results (output/error JSONL) and drive executionProgress updates.

Changes:

  • Refactors executeJob/processModel to emit results via a resultCollector instead of writing JSONL directly with shared buffered writers.
  • Centralizes terminal error handling in executeJob (abort siblings on first error, then determine final outcome from context state).
  • Updates executor_test.go to construct/start/flush the new collector in model-processing tests.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
internal/processor/worker/executor.go Switches execution to a new resultCollector interface and updates cancellation/drain paths to emit ResultItems.
internal/processor/worker/executor_test.go Updates model execution tests to use the new collector instead of outputWriters.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/processor/worker/executor.go
Comment thread internal/processor/worker/executor_test.go Outdated
@evacchi
evacchi force-pushed the refactor-result-collection branch from 45923fa to dc78183 Compare July 1, 2026 10:04
@evacchi
evacchi requested a review from Copilot July 1, 2026 10:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

Comment thread internal/processor/worker/executor.go Outdated
Comment thread internal/processor/worker/collector.go
Comment thread internal/processor/worker/collector.go
Comment thread internal/processor/worker/collector.go Outdated
Comment thread internal/processor/worker/executor_test.go
@evacchi
evacchi force-pushed the refactor-result-collection branch 3 times, most recently from 2b9139c to eaaaf20 Compare July 9, 2026 13:36
Comment thread internal/processor/worker/collector.go
evacchi added 2 commits July 9, 2026 17:53
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
Signed-off-by: Edoardo Vacchi <evacchi@users.noreply.github.com>
@evacchi
evacchi force-pushed the refactor-result-collection branch from 2a2250e to 762e139 Compare July 9, 2026 15:53
continue
}

c.progress.record(ctx, result.isSuccess())

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This introduces a new coupling between result draining and progress publication. resultCollector is a single goroutine, so if progress.record() blocks on the status store, the collector stops draining results, collect() eventually backpressures model goroutines, and executeJob() can hang even though output writes are otherwise fine. In the previous design, progress updates were best-effort work done by worker goroutines, so a slow status-store call could stall one updater but not the entire result pipeline.


func newResultCollector(outputWriter, errorWriter *bufio.Writer, progress *executionProgress, logger logr.Logger, abortFn context.CancelFunc) *resultCollector {
if abortFn == nil {
panic("resultCollector: abortFn cannot be nil")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: I think it is better to avoid panic here. Our usual convention is to return an error (or treat nil as a no-op) rather than panic in production paths.
I noticed executeJob already substitutes a no-op when requestAbortFn is nil, so this may be unreachable today, but if a future caller hits this constructor directly, a panic would take down
the process. Returning an error (or documenting/handling nil explicitly) would make that failure mode safer.

@evacchi

evacchi commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

this can also be closed as superseded by work in #580

@evacchi evacchi closed this Jul 16, 2026
@lioraron

Copy link
Copy Markdown
Collaborator

@evacchi Is this superseded by #581 which is merged?
If so pls close this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note-none Exclude from release notes (internal, CI, test, refactor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

enh: refactor job output writer + progress tracking

4 participants