Skip to content

Commit

Permalink
increase backoff_factor and add try/catch in k8s tests (apache#42940)
Browse files Browse the repository at this point in the history
  • Loading branch information
gopidesupavan authored and kunaljubce committed Oct 13, 2024
1 parent 97e14d1 commit e5d016f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions kubernetes_tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import requests
import requests.exceptions
from requests.adapters import HTTPAdapter
from urllib3.exceptions import MaxRetryError
from urllib3.util.retry import Retry

CLUSTER_FORWARDED_PORT = os.environ.get("CLUSTER_FORWARDED_PORT") or "8080"
Expand Down Expand Up @@ -125,7 +126,7 @@ def _get_session_with_retries(self):
session.auth = ("admin", "admin")
retries = Retry(
total=3,
backoff_factor=1,
backoff_factor=10,
status_forcelist=[404],
allowed_methods=Retry.DEFAULT_ALLOWED_METHODS | frozenset(["PATCH", "POST"]),
)
Expand Down Expand Up @@ -225,10 +226,16 @@ def start_dag(self, dag_id, host):
print(f"Calling [start_dag]#1 {patch_string}")
max_attempts = 10
result = {}
# This loop retries until the DAG parser finishes with max_attempts and the DAG is available for execution.
# Keep the try/catch block, as the session object has a default retry configuration.
# If a MaxRetryError is raised, it can be safely ignored, indicating that the DAG is not yet parsed.
while max_attempts:
result = self.session.patch(patch_string, json={"is_paused": False})
if result.status_code == 200:
break
try:
result = self.session.patch(patch_string, json={"is_paused": False})
if result.status_code == 200:
break
except MaxRetryError:
pass

time.sleep(30)
max_attempts -= 1
Expand Down

0 comments on commit e5d016f

Please sign in to comment.