Skip to content

Commit 6794547

Browse files
committed
pkg/aflow: add notion of flow errors
Flow errors denote failure of the flow itself, rather than an infrastructure error. A flow errors mean an expected condition in the flow when it cannot continue, and cannot produce expected outputs. For example, if we are doing something with the kernel, but the kernel build fails. Flow errors shouldn't be flagged in Fixes #6610
1 parent 592aa8f commit 6794547

File tree

4 files changed

+29
-4
lines changed

4 files changed

+29
-4
lines changed

pkg/aflow/action/crash/reproduce.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func reproduce(ctx *aflow.Context, args reproduceArgs) (reproduceResult, error)
5252
if err != nil {
5353
return reproduceResult{}, err
5454
}
55+
const noCrash = "reproducer did not crash"
5556
desc := fmt.Sprintf("kernel commit %v, kernel config hash %v, image hash %v,"+
5657
" vm %v, vm config hash %v, C repro hash %v",
5758
args.KernelCommit, hash.String(args.KernelConfig), hash.String(imageData),
@@ -91,7 +92,7 @@ func reproduce(ctx *aflow.Context, args reproduceArgs) (reproduceResult, error)
9192
}
9293
os.RemoveAll(cfg.Workdir)
9394
if results[0].Error == nil {
94-
results[0].Error = errors.New("reproducer did not crash")
95+
results[0].Error = errors.New(noCrash)
9596
}
9697
file, data := "", []byte(nil)
9798
var crashErr *instance.CrashError
@@ -106,7 +107,11 @@ func reproduce(ctx *aflow.Context, args reproduceArgs) (reproduceResult, error)
106107
return reproduceResult{}, err
107108
}
108109
if data, err := os.ReadFile(filepath.Join(dir, "error")); err == nil {
109-
return reproduceResult{}, errors.New(string(data))
110+
err := errors.New(string(data))
111+
if err.Error() == noCrash {
112+
err = aflow.FlowError(err)
113+
}
114+
return reproduceResult{}, err
110115
}
111116
data, err := os.ReadFile(filepath.Join(dir, "report"))
112117
return reproduceResult{

pkg/aflow/action/kernel/build.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func buildKernel(ctx *aflow.Context, args buildArgs) (buildResult, error) {
4747
compileCommnads := "compile_commands.json"
4848
makeArgs = append(makeArgs, path.Base(image), compileCommnads)
4949
if _, err := osutil.RunCmd(time.Hour, args.KernelSrc, "make", makeArgs...); err != nil {
50-
return err
50+
return aflow.FlowError(err)
5151
}
5252
// Remove main intermediate build files, we don't need them anymore
5353
// and they take lots of space. Keep generated source files.

pkg/aflow/execute.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package aflow
55

66
import (
77
"context"
8+
"errors"
89
"fmt"
910
"maps"
1011
"os"
@@ -70,6 +71,25 @@ func (flow *Flow) Execute(c context.Context, model, workdir string, inputs map[s
7071
return span.Results, nil
7172
}
7273

74+
// FlowError creates an error that denotes failure of the flow itself,
75+
// rather than an infrastructure error. A flow errors mean an expected
76+
// condition in the flow when it cannot continue, and cannot produce
77+
// expected outputs. For example, if we are doing something with the kernel,
78+
// but the kernel build fails. Flow errors shouldn't be flagged in
79+
// infrastructure monitoring.
80+
func FlowError(err error) error {
81+
return &flowError{err}
82+
}
83+
84+
func IsFlowError(err error) bool {
85+
var flowErr *flowError
86+
return errors.As(err, &flowErr)
87+
}
88+
89+
type flowError struct {
90+
error
91+
}
92+
7393
type (
7494
onEvent func(*trajectory.Span) error
7595
generateContentFunc func(*genai.GenerateContentConfig, []*genai.Content) (

syz-agent/agent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func (s *Server) poll(ctx context.Context) (
199199
if err := s.dash.AIJobDone(doneReq); err != nil {
200200
return false, err
201201
}
202-
if jobErr != nil {
202+
if jobErr != nil && !aflow.IsFlowError(jobErr) {
203203
return false, jobErr
204204
}
205205
return true, nil

0 commit comments

Comments
 (0)