Skip to content
Snippets Groups Projects
Commit 9a426f8e authored by Alex Kalderimis's avatar Alex Kalderimis
Browse files

Add retry mechanism

this does not work for me, but is here as a record of what we have
tried.
parent b0cda10a
No related merge requests found
......@@ -2,13 +2,15 @@
module DesignManagement
module RunsDesignActions
MAX_TRIES = 3
NoActions = Class.new(StandardError)
# this concern requires the following methods to be implemented:
# current_user, target_branch, repository, commit_message
#
# @raise [NoActions] if actions are empty
def run_actions(actions)
def run_actions(actions, tries = MAX_TRIES)
raise NoActions if actions.empty?
repository.create_if_not_exists
......@@ -18,6 +20,18 @@ def run_actions(actions)
actions: actions.map(&:gitaly_action))
::DesignManagement::Version.create_for_designs(actions, sha)
rescue Gitlab::Git::CommandError => e
retry_or_fail(actions, e, tries)
end
private
def retry_or_fail(actions, error, tries)
if tries < MAX_TRIES
run_actions(actions, tries - 1)
else
raise error
end
end
end
end
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment