Skip to content

Commit

Permalink
fix: updated retry/error messages with clearer detail
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec committed Sep 29, 2021
1 parent e02aec9 commit e55b950
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions runner/sidecar/in.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ func connectIn(ctx context.Context, sink func(context.Context, []byte) error) (f
inFlight.Inc()
defer inFlight.Dec()
if _, err := fifo.Write(data); err != nil {
return fmt.Errorf("failed to send to main: %w", err)
return fmt.Errorf("failed to write to fifo: %w", err)
}
if _, err := fifo.Write([]byte("\n")); err != nil {
return fmt.Errorf("failed to send to main: %w", err)
return fmt.Errorf("failed to write to fifo: %w", err)
}
return nil
}, nil
Expand Down Expand Up @@ -103,12 +103,12 @@ func connectIn(ctx context.Context, sink func(context.Context, []byte) error) (f
return err
}
if resp, err := httpClient.Do(req); err != nil {
return fmt.Errorf("failed to send to main: %w", err)
return fmt.Errorf("failed to execute HTTP request: %w", err)
} else {
body, _ := ioutil.ReadAll(resp.Body)
_ = resp.Body.Close()
if resp.StatusCode >= 300 {
return fmt.Errorf("failed to send to main: %q %q", resp.Status, body)
return fmt.Errorf("HTTP request failed: %q %q", resp.Status, body)
}
if resp.StatusCode == 201 {
return sink(ctx, body)
Expand Down
5 changes: 3 additions & 2 deletions runner/sidecar/sources.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ func connectSources(ctx context.Context, process func(context.Context, []byte) e
if err == nil {
return nil
}
logger.Error(err, "⚠ →", "source", sourceName, "backoffSteps", backoff.Steps)
if backoff.Steps <= 0 {
giveUp := backoff.Steps <= 0
logger.Error(err, "failed to send process message", "source", sourceName, "backoffSteps", backoff.Steps, "giveUp", giveUp)
if giveUp {
errorsCounter.WithLabelValues(sourceName, fmt.Sprint(replica)).Inc()
return err
}
Expand Down

0 comments on commit e55b950

Please sign in to comment.