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

vincbeck 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 e781aef1a7 aws waiter util: log status info with error level on waiter 
error (#32247)
e781aef1a7 is described below

commit e781aef1a76f594392e0b8c4a13bbccef4bf8969
Author: RaphaĆ«l Vandon <[email protected]>
AuthorDate: Thu Jun 29 11:40:17 2023 -0700

    aws waiter util: log status info with error level on waiter error (#32247)
---
 .../amazon/aws/utils/waiter_with_logging.py          |  2 ++
 .../amazon/aws/utils/test_waiter_with_logging.py     | 20 ++++++--------------
 2 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/airflow/providers/amazon/aws/utils/waiter_with_logging.py 
b/airflow/providers/amazon/aws/utils/waiter_with_logging.py
index 5f66b01cd2..1e506927a1 100644
--- a/airflow/providers/amazon/aws/utils/waiter_with_logging.py
+++ b/airflow/providers/amazon/aws/utils/waiter_with_logging.py
@@ -71,6 +71,7 @@ def wait(
             break
         except WaiterError as error:
             if "terminal failure" in str(error):
+                log.error("%s: %s", failure_message, 
_LazyStatusFormatter(status_args, error.last_response))
                 raise AirflowException(f"{failure_message}: {error}")
 
             log.info("%s: %s", status_message, 
_LazyStatusFormatter(status_args, error.last_response))
@@ -122,6 +123,7 @@ async def async_wait(
             break
         except WaiterError as error:
             if "terminal failure" in str(error):
+                log.error("%s: %s", failure_message, 
_LazyStatusFormatter(status_args, error.last_response))
                 raise AirflowException(f"{failure_message}: {error}")
 
             log.info("%s: %s", status_message, 
_LazyStatusFormatter(status_args, error.last_response))
diff --git a/tests/providers/amazon/aws/utils/test_waiter_with_logging.py 
b/tests/providers/amazon/aws/utils/test_waiter_with_logging.py
index 03427c2ac5..2f753b84f3 100644
--- a/tests/providers/amazon/aws/utils/test_waiter_with_logging.py
+++ b/tests/providers/amazon/aws/utils/test_waiter_with_logging.py
@@ -136,7 +136,7 @@ class TestWaiter:
             },
         )
 
-        mock_waiter.wait.call_count == 11
+        assert mock_waiter.wait.call_count == 2
         mock_sleep.assert_called_with(123)
         assert (
             caplog.record_tuples
@@ -165,6 +165,7 @@ class TestWaiter:
             last_response=generate_response("Failure"),
         )
         mock_waiter.wait.side_effect = [error, error, error, failure_error]
+
         with pytest.raises(AirflowException) as exc:
             wait(
                 waiter=mock_waiter,
@@ -175,6 +176,7 @@ class TestWaiter:
                 status_message="test status message",
                 status_args=["Status.State"],
             )
+
         assert "test failure message" in str(exc)
         mock_waiter.wait.assert_called_with(
             **{"test_arg": "test_value"},
@@ -183,17 +185,7 @@ class TestWaiter:
             },
         )
         assert mock_waiter.wait.call_count == 4
-        assert (
-            caplog.record_tuples
-            == [
-                (
-                    "airflow.providers.amazon.aws.utils.waiter_with_logging",
-                    logging.INFO,
-                    "test status message: Pending",
-                )
-            ]
-            * 3
-        )
+        assert caplog.messages == ["test status message: Pending"] * 3 + 
["test failure message: Failure"]
 
     @mock.patch("time.sleep")
     def test_wait_with_list_response(self, mock_sleep, caplog):
@@ -279,7 +271,7 @@ class TestWaiter:
                 "MaxAttempts": 1,
             },
         )
-        mock_waiter.wait.call_count == 3
+        assert mock_waiter.wait.call_count == 3
         mock_sleep.assert_called_with(123)
         assert (
             caplog.record_tuples
@@ -320,7 +312,7 @@ class TestWaiter:
             status_message="test status message",
             status_args=["Clusters[0].Status", "Clusters[0].StatusDetails", 
"Clusters[0].ClusterName"],
         )
-        mock_waiter.wait.call_count == 3
+        assert mock_waiter.wait.call_count == 3
         mock_sleep.assert_called_with(123)
         assert (
             caplog.record_tuples

Reply via email to