This is an automated email from the ASF dual-hosted git repository.
eladkal 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 4e3c964a0e2 bugfix: Add handling for unhealthy state in
`AzureContainerInstancesOperator` (#49688)
4e3c964a0e2 is described below
commit 4e3c964a0e203aa0118c93eee59fdb07bcea4ca4
Author: Elad Kalif <[email protected]>
AuthorDate: Thu Apr 24 12:43:57 2025 +0300
bugfix: Add handling for unhealthy state in
`AzureContainerInstancesOperator` (#49688)
* bugfix: Add handling for unhealthy state in
`AzureContainerInstancesOperator`
---
.../providers/microsoft/azure/operators/container_instances.py | 4 ++++
.../tests/unit/microsoft/azure/operators/test_container_instances.py | 5 +++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git
a/providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/container_instances.py
b/providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/container_instances.py
index 089baefb96c..ea1cfc4eb2c 100644
---
a/providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/container_instances.py
+++
b/providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/container_instances.py
@@ -388,6 +388,10 @@ class AzureContainerInstancesOperator(BaseOperator):
self.log.info("Container exited with detail_status %s",
detail_status)
return exit_code
+ if state == "Unhealthy":
+ self.log.error("Azure provision unhealthy")
+ return 1
+
if state == "Failed":
self.log.error("Azure provision failure")
return 1
diff --git
a/providers/microsoft/azure/tests/unit/microsoft/azure/operators/test_container_instances.py
b/providers/microsoft/azure/tests/unit/microsoft/azure/operators/test_container_instances.py
index 8985927ecfb..807e2304d6b 100644
---
a/providers/microsoft/azure/tests/unit/microsoft/azure/operators/test_container_instances.py
+++
b/providers/microsoft/azure/tests/unit/microsoft/azure/operators/test_container_instances.py
@@ -161,8 +161,9 @@ class TestACIOperator:
assert aci_mock.return_value.delete.call_count == 1
@mock.patch("airflow.providers.microsoft.azure.operators.container_instances.AzureContainerInstanceHook")
- def test_execute_with_failures_without_removal(self, aci_mock):
- expected_cg = make_mock_container(state="Terminated", exit_code=1,
detail_status="test")
+ @pytest.mark.parametrize("state", ["Terminated", "Unhealthy"])
+ def test_execute_with_failures_without_removal(self, aci_mock, state):
+ expected_cg = make_mock_container(state=state, exit_code=1,
detail_status="test")
aci_mock.return_value.get_state.return_value = expected_cg
aci_mock.return_value.exists.return_value = False