Skip to content

Commit

Permalink
Remove retry on rate limit. (#1691)
Browse files Browse the repository at this point in the history
* disable retry

* retry for 5xx

* bump version
  • Loading branch information
cbartz authored Jun 3, 2024
1 parent 24f5672 commit 7bbdcda
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[tool.poetry]
name = "repo-policy-compliance"
version = "1.8.2"
version = "1.8.3"
description = "Checks GitHub repository settings for compliance with policy"
authors = ["Canonical IS DevOps <launchpad.net/~canonical-is-devops>"]
license = "Apache 2.0"
Expand Down
12 changes: 11 additions & 1 deletion repo_policy_compliance/github_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from github.Auth import Token
from github.Branch import Branch
from github.Repository import Repository
from urllib3 import Retry

from repo_policy_compliance.exceptions import (
ConfigurationError,
Expand Down Expand Up @@ -42,7 +43,16 @@ def get() -> Github:
f"The {GITHUB_TOKEN_ENV_NAME} environment variable was not provided or empty, "
f"it is needed for interactions with GitHub, got: {github_token!r}"
)
return Github(auth=Token(github_token))
# Only retry on 5xx and only retry once after 20 secs
retry_config = Retry(
total=1,
backoff_factor=20,
status_forcelist=list(range(500, 600)),
respect_retry_after_header=False,
raise_on_status=False,
raise_on_redirect=False,
)
return Github(auth=Token(github_token), retry=retry_config)


def inject(func: Callable[Concatenate[Github, P], R]) -> Callable[P, R]:
Expand Down
2 changes: 1 addition & 1 deletion rockcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

name: repo-policy-compliance
base: [email protected]
version: '1.8.2'
version: '1.8.3'
summary: Check the repository setup for policy compliance
description: |
Used to check whether a GitHub repository complies with expected policies.
Expand Down
10 changes: 5 additions & 5 deletions src-docs/github_client.py.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Module for GitHub client.

---

<a href="../repo_policy_compliance/github_client.py#L30"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../repo_policy_compliance/github_client.py#L31"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `get`

Expand All @@ -35,7 +35,7 @@ Get a GitHub client.

---

<a href="../repo_policy_compliance/github_client.py#L48"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../repo_policy_compliance/github_client.py#L58"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `inject`

Expand All @@ -59,7 +59,7 @@ Injects a GitHub client as the first argument to a function.

---

<a href="../repo_policy_compliance/github_client.py#L98"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../repo_policy_compliance/github_client.py#L108"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `get_collaborators`

Expand Down Expand Up @@ -89,7 +89,7 @@ Get collaborators with a given affiliation and permission.

---

<a href="../repo_policy_compliance/github_client.py#L133"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../repo_policy_compliance/github_client.py#L143"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `get_branch`

Expand Down Expand Up @@ -119,7 +119,7 @@ Get the branch for the check.

---

<a href="../repo_policy_compliance/github_client.py#L148"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="../repo_policy_compliance/github_client.py#L158"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>function</kbd> `get_collaborator_permission`

Expand Down

0 comments on commit 7bbdcda

Please sign in to comment.