Skip to content

Commit 5aa46d6

Browse files
authored
exp backoff fails when datagatherers have no error (#190)
The error formatting would run even with a nil error leading to a seg fault. This now only runs if an error is present. The return has also been corrected to stop the exp-backoff always running Signed-off-by: Jamie Leppard <[email protected]> Co-authored-by: Jamie Leppard <[email protected]>
1 parent 653159c commit 5aa46d6

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

pkg/agent/run.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,16 +239,18 @@ func gatherData(ctx context.Context, config Config) []*api.DataReading {
239239
})
240240
}
241241
}
242-
dgError.ErrorFormat = func(es []error) string {
243-
points := make([]string, len(es))
244-
for i, err := range es {
245-
points[i] = fmt.Sprintf("* %s", err)
242+
if dgError != nil {
243+
dgError.ErrorFormat = func(es []error) string {
244+
points := make([]string, len(es))
245+
for i, err := range es {
246+
points[i] = fmt.Sprintf("* %s", err)
247+
}
248+
return fmt.Sprintf(
249+
"The following %d data gatherer(s) have failed:\n\t%s",
250+
len(es), strings.Join(points, "\n\t"))
246251
}
247-
return fmt.Sprintf(
248-
"The following %d data gatherer(s) have failed:\n\t%s",
249-
len(es), strings.Join(points, "\n\t"))
250252
}
251-
return dgError
253+
return dgError.ErrorOrNil()
252254
}
253255

254256
err := backoff.RetryNotify(getReadings, backOff, notify)

0 commit comments

Comments
 (0)