This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch v2-10-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v2-10-test by this push:
     new 52ecdb1f78 increase backoff_factor and add try/catch in k8s tests 
(#42940) (#43030)
52ecdb1f78 is described below

commit 52ecdb1f78f4b7634f78df799c2eadb6f82a89e1
Author: GPK <gopidesupa...@gmail.com>
AuthorDate: Tue Oct 15 12:44:34 2024 +0100

    increase backoff_factor and add try/catch in k8s tests (#42940) (#43030)
---
 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

Reply via email to