Skip to content

Commit

Permalink
Add retry to push_manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
shonfeder committed Aug 21, 2024
1 parent 411bb6d commit 3c3554c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions plugins/docker/push_manifest.ml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@ end
let create_cmd ~config ~tag {Value.manifests} =
Cmd.docker ~config ~docker_context:None (["manifest"; "create"; tag] @ manifests)

let push_cmd ~config tag =
Cmd.docker ~config ~docker_context:None ["manifest"; "push"; tag]
let docker_manifest ~job ~config tag =
let retry_attempts = 5 in
let cmd = Cmd.docker ~config ~docker_context:None ["manifest"; "push"; tag] in
let operation () =
Current.Process.check_output ~cancellable:true ~job cmd
>|= Result.map_error (fun (`Msg err) -> `Retry err)
in
Current.Retry.(operation |> on_error |> with_sleep |> n_times retry_attempts)

let or_fail = function
| Ok x -> x
Expand All @@ -58,7 +64,7 @@ let publish auth job tag value =
| Error _ as e -> Lwt.return e
| Ok () ->
Lwt_mutex.with_lock push_mutex @@ fun () ->
Current.Process.check_output ~cancellable:true ~job (push_cmd ~config tag) >>!= fun output ->
docker_manifest ~job ~config tag >>!= fun output ->
(* docker-manifest is still experimental and doesn't have a sensible output format yet. *)
Current.Job.write job output;
let output = String.trim output in
Expand Down

0 comments on commit 3c3554c

Please sign in to comment.