Skip to content

Commit 28e158f

Browse files
committed
Merge remote-tracking branch 'upstream/main' into rhoai-3.5
2 parents b4da539 + 843079d commit 28e158f

12 files changed

Lines changed: 477 additions & 18 deletions

File tree

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ require (
1414
github.com/go-resty/resty/v2 v2.17.2
1515
github.com/google/uuid v1.6.0
1616
github.com/jackc/pgx/v5 v5.10.0
17-
github.com/llm-d-incubation/llm-d-async/api v0.7.2
18-
github.com/llm-d-incubation/llm-d-async/producer v0.7.2
17+
github.com/llm-d-incubation/llm-d-async/api v0.7.3
18+
github.com/llm-d-incubation/llm-d-async/producer v0.7.3
1919
github.com/pashagolub/pgxmock/v4 v4.9.0
2020
github.com/prometheus/client_golang v1.23.2
2121
github.com/quasilyte/go-ruleguard/dsl v0.3.23

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
8888
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
8989
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
9090
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
91-
github.com/llm-d-incubation/llm-d-async/api v0.7.2 h1:sf6iFDa5LpVoKDYiOOlsbnv+6Ykj5TA22yRqMdIbOfY=
92-
github.com/llm-d-incubation/llm-d-async/api v0.7.2/go.mod h1:m2zJUwD/AZypJv8RPws3uvCnfQoNW7iv+hH9wPk/Xw4=
93-
github.com/llm-d-incubation/llm-d-async/producer v0.7.2 h1:hhnLqi+MXq8kBjsQhnUCWYtTCG6uFTZLCH296CZMlpY=
94-
github.com/llm-d-incubation/llm-d-async/producer v0.7.2/go.mod h1:IrClO4XwMtgLRnlkAqO1LDsuqmwtQjELDabT2f+5d40=
91+
github.com/llm-d-incubation/llm-d-async/api v0.7.3 h1:OI4zlNdKeXrWa9Q9AhFOSvJZvLC84Nnsv3maF4d8Tns=
92+
github.com/llm-d-incubation/llm-d-async/api v0.7.3/go.mod h1:m2zJUwD/AZypJv8RPws3uvCnfQoNW7iv+hH9wPk/Xw4=
93+
github.com/llm-d-incubation/llm-d-async/producer v0.7.3 h1:f06rUZ92g/2gQmcrquYYd5LNGeCYffb1vZdP+7luiA0=
94+
github.com/llm-d-incubation/llm-d-async/producer v0.7.3/go.mod h1:7FVFV0ggHyaSbD33DP1V68tV7bOVKqjAezd8UgD9Qik=
9595
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
9696
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
9797
github.com/pashagolub/pgxmock/v4 v4.9.0 h1:itlO8nrVRnzkdMBXLs8pWUyyB2PC3Gku0WGIj/gGl7I=

internal/processor/worker/executor.go

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -679,11 +679,23 @@ func (p *Processor) processModelAsync(
679679
delete(pending, resp.RequestID)
680680
}
681681

682+
// Best-effort: tell the dispatcher to drop still-pending requests before
683+
// dispatch. Use a detached timeout — requestAbortCtx is often already
684+
// cancelled when we reach this path.
685+
if len(pending) > 0 {
686+
cancelCtx, cancelFn := context.WithTimeout(context.Background(), 5*time.Second)
687+
if err := asyncClient.Cancel(cancelCtx); err != nil {
688+
logger.Error(err, "Failed to cancel pending async requests", "pendingCount", len(pending))
689+
}
690+
cancelFn()
691+
}
692+
682693
// Drain submitted-but-uncollected requests as errors so that
683-
// output_lines + error_lines == total_requests.
694+
// output_lines + error_lines == total_requests. Error code follows the
695+
// same abort-reason priority as drainAndFinalize.
696+
errCode, errMsg := uncollectedPendingError(mainCtx, sloCtx, userCancelCtx, modelErr)
684697
for _, pr := range pending {
685-
out := newErrorOutputLine(pr.batchReqID, pr.customID,
686-
string(batch_types.ErrCodeBatchExpired), "result not collected before deadline")
698+
out := newErrorOutputLine(pr.batchReqID, pr.customID, string(errCode), errMsg)
687699
lineBytes, err := json.Marshal(out)
688700
if err != nil {
689701
return fmt.Errorf("marshal uncollected error line: %w", err)
@@ -699,6 +711,30 @@ func (p *Processor) processModelAsync(
699711
inputFile, entries[submitCount:], writers, progress, modelErr, logger, len(entries), 0)
700712
}
701713

714+
// uncollectedPendingError selects the error code/message for submitted-but-
715+
// uncollected async requests, matching drainAndFinalize's abort-reason order.
716+
// Context parameter order mirrors drainAndFinalize (minus requestAbortCtx).
717+
func uncollectedPendingError(
718+
mainCtx, sloCtx, userCancelCtx context.Context,
719+
modelErr error,
720+
) (batch_types.BatchErrorCode, string) {
721+
switch {
722+
case errors.Is(sloCtx.Err(), context.DeadlineExceeded):
723+
return batch_types.ErrCodeBatchExpired, batch_types.ErrCodeBatchExpired.Message()
724+
case userCancelCtx.Err() != nil:
725+
return batch_types.ErrCodeBatchCancelled, batch_types.ErrCodeBatchCancelled.Message()
726+
case modelErr != nil:
727+
return batch_types.ErrCodeBatchFailed, batch_types.ErrCodeBatchFailed.Message()
728+
case mainCtx.Err() != nil:
729+
// SIGTERM: leave terminalization to orphan recovery, but still record
730+
// lines so completed+failed == total for this model pass.
731+
return batch_types.ErrCodeBatchFailed, batch_types.ErrCodeBatchFailed.Message()
732+
default:
733+
// Sibling abort or collect interrupted without a classified reason.
734+
return batch_types.ErrCodeBatchFailed, batch_types.ErrCodeBatchFailed.Message()
735+
}
736+
}
737+
702738
// drainAndFinalize drains undispatched entries based on termination reason and
703739
// returns the appropriate sentinel error. Shared by processModel and processModelAsync.
704740
func (p *Processor) drainAndFinalize(

0 commit comments

Comments
 (0)