Preserve operational timeouts when selecting run failures
This commit is contained in:
@@ -10,6 +10,8 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"go.maximumdirect.net/promptkit"
|
||||
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/core/fileio"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/core/source"
|
||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/contracts"
|
||||
@@ -404,28 +406,27 @@ func selectRunError(parent context.Context, values []orderedRunError) error {
|
||||
}
|
||||
hasReal := false
|
||||
for _, value := range values {
|
||||
if !errors.Is(value.err, context.Canceled) && !errors.Is(value.err, context.DeadlineExceeded) {
|
||||
if !isSiblingCancellation(value.err) {
|
||||
hasReal = true
|
||||
break
|
||||
}
|
||||
}
|
||||
filtered := values[:0]
|
||||
var best *orderedRunError
|
||||
for _, value := range values {
|
||||
if hasReal && (errors.Is(value.err, context.Canceled) || errors.Is(value.err, context.DeadlineExceeded)) {
|
||||
if hasReal && isSiblingCancellation(value.err) {
|
||||
continue
|
||||
}
|
||||
filtered = append(filtered, value)
|
||||
if best == nil || value.stage < best.stage || value.stage == best.stage && (value.lane < best.lane || value.lane == best.lane && value.chunk < best.chunk) {
|
||||
best = &value
|
||||
}
|
||||
}
|
||||
sort.SliceStable(filtered, func(i, j int) bool {
|
||||
if filtered[i].stage != filtered[j].stage {
|
||||
return filtered[i].stage < filtered[j].stage
|
||||
}
|
||||
if filtered[i].lane != filtered[j].lane {
|
||||
return filtered[i].lane < filtered[j].lane
|
||||
}
|
||||
return filtered[i].chunk < filtered[j].chunk
|
||||
})
|
||||
return filtered[0].err
|
||||
return best.err
|
||||
}
|
||||
|
||||
// The runner cancels siblings, but does not give them a separate deadline.
|
||||
// Deadline-shaped provider/native failures remain real when the caller is active.
|
||||
func isSiblingCancellation(err error) bool {
|
||||
return errors.Is(err, context.Canceled) && !errors.Is(err, promptkit.ErrOperationTimeout)
|
||||
}
|
||||
|
||||
func mergeLaneOutput(dst *RunOutput, src RunOutput) {
|
||||
|
||||
Reference in New Issue
Block a user