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

Do not retry on not found resource #1731

Open
wants to merge 1 commit into
base: main
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
9 changes: 7 additions & 2 deletions agent/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (d Download) Start() error {
roko.WithMaxAttempts(d.conf.Retries),
roko.WithStrategy(roko.Constant(5*time.Second)),
).Do(func(r *roko.Retrier) error {
err := d.try()
err := d.try(r)
if err != nil {
d.logger.Warn("Error trying to download %s (%s) %s", d.conf.URL, err, r)
}
Expand Down Expand Up @@ -96,7 +96,7 @@ func getTargetPath(path string, destination string) string {
return targetFile
}

func (d Download) try() error {
func (d Download) try(r *retry.Retrier) error {
targetFile := getTargetPath(d.conf.Path, d.conf.Destination)
targetDirectory, _ := filepath.Split(targetFile)

Expand Down Expand Up @@ -129,6 +129,11 @@ func (d Download) try() error {
}
}

// Skip retry on 404 as this is unnecessary
if response.StatusCode == 404 {
r.Break()
}

return &downloadError{response.Status}
}

Expand Down