Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase backoff_factor and add try/catch in k8s tests #42940

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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