Skip to content

Commit

Permalink
retry tasks at least once
Browse files Browse the repository at this point in the history
  • Loading branch information
damoon committed Nov 23, 2020
1 parent 94875d2 commit 31d8579
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions pkg/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ func (s Service) inspect(w http.ResponseWriter, r *http.Request) {
script := fmt.Sprintf(`
set -euo pipefail
mkdir %s
skopeo copy --quiet --retry-times 3 --src-tls-verify=false docker://%s dir://%s
skopeo copy --quiet --retry-times 3 --src-tls-verify=false docker://%s dir://%s || \
skopeo copy --quiet --retry-times 3 --src-tls-verify=false docker://%s dir://%s
skopeo inspect dir://%s
rm -r %s
`, randomID, image, randomID, randomID, randomID)
`, randomID, image, randomID, image, randomID, randomID, randomID)

ctx, cancel := context.WithTimeout(r.Context(), 5*time.Second)
defer cancel()
Expand Down
2 changes: 1 addition & 1 deletion pkg/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (s Service) pullImage(w http.ResponseWriter, r *http.Request) {
}

o := &output{w: w}
err = scheduler(r.Context(), o, "pull", script, dockerCfg.mustToJSON())
err = scheduler(r.Context(), o, "pull", script+" || "+script, dockerCfg.mustToJSON())
if err != nil {
log.Printf("execute pull: %v", err)
o.Errorf("execute pull: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (s Service) pushImage(w http.ResponseWriter, r *http.Request) {
}

o := &output{w: w}
err = scheduler(r.Context(), o, "push", script, dockerCfg.mustToJSON())
err = scheduler(r.Context(), o, "push", script+" || "+script, dockerCfg.mustToJSON())
if err != nil {
log.Printf("execute push: %v", err)
o.Errorf("execute push: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (s Service) tagImage(w http.ResponseWriter, r *http.Request) {
}

o := &bytes.Buffer{}
err = scheduler(r.Context(), o, "tag", script, "")
err = scheduler(r.Context(), o, "tag", script+" || "+script, "")
if err != nil {
log.Printf("execute tag: %v", err)
w.WriteHeader(http.StatusInternalServerError)
Expand Down

0 comments on commit 31d8579

Please sign in to comment.