Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
fix: Retry deleting a branch if GitHub says it's unknown
Browse files Browse the repository at this point in the history
Try to fix #687 by allowing
retries on `delete_branch`. This may prevent the issue we've seen in
`create_private_to_public_pr.py` where the deletion of a newly created
branch occasionally fails with a 404.
  • Loading branch information
timmc-edx committed Aug 21, 2023
1 parent 1eb88cb commit b35fcf4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tubular/github_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,8 +664,17 @@ def get_commits_by_branch(self, branch):
branch = self.github_repo.get_branch(branch)
return self.github_repo.get_commits(branch.commit.sha)

@backoff.on_exception(backoff.expo, (RateLimitExceededException, socket.timeout), max_tries=7,
jitter=backoff.random_jitter, on_backoff=_backoff_logger)
@backoff.on_exception(
backoff.expo,
(
RateLimitExceededException, socket.timeout,
# It seems we can sometimes try to delete too
# quickly after having created a branch:
# https://github.com/openedx/tubular/issues/687
UnknownObjectException,
),
max_tries=7, jitter=backoff.random_jitter, on_backoff=_backoff_logger,
)
def delete_branch(self, branch_name):
"""
Call GitHub's delete ref (branch) API
Expand Down

0 comments on commit b35fcf4

Please sign in to comment.