mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Fix the global ROBOT_TOKEN, do not retry unnecessary
This commit is contained in:
parent
ca19f20aff
commit
b423e04ab0
@ -10,8 +10,8 @@ from typing import Any, Callable, List
|
||||
|
||||
import requests # type: ignore
|
||||
|
||||
import get_robot_token as grt # we need an updated ROBOT_TOKEN
|
||||
from ci_config import CI_CONFIG
|
||||
from get_robot_token import ROBOT_TOKEN, get_best_robot_token
|
||||
|
||||
DOWNLOAD_RETRIES_COUNT = 5
|
||||
|
||||
@ -56,13 +56,18 @@ def get_gh_api(
|
||||
def set_auth_header():
|
||||
if "headers" in kwargs:
|
||||
if "Authorization" not in kwargs["headers"]:
|
||||
kwargs["headers"]["Authorization"] = f"Bearer {get_best_robot_token()}"
|
||||
kwargs["headers"][
|
||||
"Authorization"
|
||||
] = f"Bearer {grt.get_best_robot_token()}"
|
||||
else:
|
||||
kwargs["headers"] = {"Authorization": f"Bearer {get_best_robot_token()}"}
|
||||
kwargs["headers"] = {
|
||||
"Authorization": f"Bearer {grt.get_best_robot_token()}"
|
||||
}
|
||||
|
||||
if ROBOT_TOKEN is not None:
|
||||
if grt.ROBOT_TOKEN is not None:
|
||||
set_auth_header()
|
||||
|
||||
need_retry = False
|
||||
for _ in range(retries):
|
||||
try:
|
||||
response = get_with_retries(url, 1, sleep, **kwargs)
|
||||
@ -78,8 +83,10 @@ def get_gh_api(
|
||||
"Received rate limit exception, setting the auth header and retry"
|
||||
)
|
||||
set_auth_header()
|
||||
need_retry = True
|
||||
break
|
||||
|
||||
if need_retry:
|
||||
return get_with_retries(url, retries, sleep, **kwargs)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user