Skip to content

Commit

Permalink
jsonchecker: retry on EOF/UnexpectedEOF in unmarshaller
Browse files Browse the repository at this point in the history
I ran into a corner case in CI a few times where it seems that the exporter is in the
middle of writing an event when the jsonchecker decides to open the file and check it. In
this case, the unmarshaller will bubble up either an EOF or UnexpectedEOF error which will
fail the test. To handle this, let's just treat these errors the same way we treat regular
JSON EOF: by retrying after a few seconds.

Signed-off-by: William Findlay <[email protected]>
  • Loading branch information
willfindlay authored and kkourt committed Dec 12, 2022
1 parent 0f514cf commit 56e424a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/jsonchecker/jsonchecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ func JsonCheck(jsonFile *os.File, checker ec.MultiEventChecker, log *logrus.Logg
var dbgErr *DebugError
var ev tetragon.GetEventsResponse
if err := dec.Decode(&ev); err != nil {
if errors.Is(err, io.ErrUnexpectedEOF) || errors.Is(err, io.EOF) {
return &JsonEOF{
count: count,
err: fmt.Errorf("unmarshal failed: %w", err),
}
}
return fmt.Errorf("unmarshal failed: %w", err)
}
count++
Expand Down

0 comments on commit 56e424a

Please sign in to comment.