Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add retry mechanism for datadurability check #380

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions pkg/check/datadurability/datadurability.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"context"
"fmt"
"io"
"net/http"
"slices"
"sync"
"time"
Expand All @@ -18,15 +19,19 @@ import (
)

type Options struct {
Ref string
Concurrency int
MaxAttempts int
Ref string
Concurrency int
MaxAttempts int
RetryAttempts int
RetryWait time.Duration
}

func NewDefaultOptions() Options {
return Options{
Concurrency: 10,
MaxAttempts: 10,
Concurrency: 10,
MaxAttempts: 10,
RetryAttempts: 3,
RetryWait: 5 * time.Second,
}
}

Expand Down Expand Up @@ -99,9 +104,16 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, o interf
c.metrics.ChunkDownloadAttempts.Inc()
cache := false
chunkStart := time.Now()
d, err = node.Client().DownloadChunk(ctx, ref, "", &api.DownloadOptions{Cache: &cache})
for retry := 0; retry < opts.RetryAttempts; retry++ {
d, err = node.Client().DownloadChunk(ctx, ref, "", &api.DownloadOptions{Cache: &cache})
acha-bill marked this conversation as resolved.
Show resolved Hide resolved
if err == nil || api.IsHTTPStatusErrorCode(err, http.StatusNotFound) {
break
}
c.logger.Debugf("download failed. %s (%d of %d). retry=%d chunk=%s node=%s err=%v", percentage(i, len(chunkRefs)), i, len(chunkRefs), retry, ref, node.Name(), err)
time.Sleep(opts.RetryWait)
}
if err != nil {
c.logger.Errorf("download failed. %s (%d of %d). chunk=%s node=%s err=%v", percentage(i, len(chunkRefs)), i, len(chunkRefs), ref, node.Name(), err)
c.logger.Errorf("download failed after %d retries. %s (%d of %d). chunk=%s node=%s err=%v", opts.RetryAttempts, percentage(i, len(chunkRefs)), i, len(chunkRefs), ref, node.Name(), err)
c.metrics.ChunkDownloadErrors.Inc()
once.Do(func() {
c.metrics.FileDownloadAttempts.Inc()
Expand Down
Loading