This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 15df46590e increase backoff_factor and add try/catch in k8s tests
(#42940)
15df46590e is described below
commit 15df46590ea13c2e8b71324fad0b77da8eaa7167
Author: GPK <[email protected]>
AuthorDate: Fri Oct 11 20:03:42 2024 +0100
increase backoff_factor and add try/catch in k8s tests (#42940)
---
kubernetes_tests/test_base.py | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/kubernetes_tests/test_base.py b/kubernetes_tests/test_base.py
index ac311daa52..6929128173 100644
--- a/kubernetes_tests/test_base.py
+++ b/kubernetes_tests/test_base.py
@@ -29,6 +29,7 @@ import re2
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"
@@ -125,7 +126,7 @@ class BaseK8STest:
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"]),
)
@@ -225,10 +226,16 @@ class BaseK8STest:
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