Skip to content

Commit

Permalink
Ssh pushback
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCutter committed Aug 1, 2024
1 parent e00df1d commit 03cc388
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion hammer/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package main
import (
"bytes"
"context"
"errors"
"fmt"
"io"
"net/http"
Expand All @@ -31,6 +32,8 @@ import (
"k8s.io/klog/v2"
)

var ErrRetry = errors.New("retry")

// newLogClientsFromFlags returns a fetcher and a writer that will read
// and write leaves to all logs in the `log_url` flag set.
func newLogClientsFromFlags() (*roundRobinFetcher, *roundRobinLeafWriter) {
Expand Down Expand Up @@ -166,7 +169,7 @@ func (w httpLeafWriter) Write(ctx context.Context, newLeaf []byte) (uint64, erro
// These status codes may indicate a delay before retrying, so handle that here:
retryDelay(resp.Header.Get("RetryAfter"), time.Second)

return 0, fmt.Errorf("log not available. Status code: %d. Body: %q", resp.StatusCode, body)
return 0, fmt.Errorf("log not available. Status code: %d. Body: %q %w", resp.StatusCode, body, ErrRetry)
default:
return 0, fmt.Errorf("write leaf was not OK. Status code: %d. Body: %q", resp.StatusCode, body)
}
Expand Down
4 changes: 3 additions & 1 deletion hammer/workers.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,9 @@ func (w *LogWriter) Run(ctx context.Context) {
lt := leafTime{queuedAt: time.Now()}
index, err := w.writer(ctx, newLeaf)
if err != nil {
w.errChan <- fmt.Errorf("failed to create request: %v", err)
if !errors.Is(ErrRetry, err) {
w.errChan <- fmt.Errorf("failed to create request: %w", err)
}
continue
}
lt.idx, lt.assignedAt = index, time.Now()
Expand Down

0 comments on commit 03cc388

Please sign in to comment.