cruseakshay commented on code in PR #62772:
URL: https://github.com/apache/airflow/pull/62772#discussion_r3079162204


##########
providers/microsoft/azure/src/airflow/providers/microsoft/azure/operators/container_instances.py:
##########
@@ -381,13 +395,36 @@ def execute(self, context: Context) -> int:
                 identity=self.identity,
             )
 
-            self._ci_hook.create_or_update(self.resource_group, self.name, 
container_group)
+            self.hook.create_or_update(self.resource_group, self.name, 
container_group)
 
             self.log.info("Container group started %s/%s", 
self.resource_group, self.name)
 
+            if self.deferrable:
+                cg_state = self.hook.get_state(self.resource_group, self.name)
+                instance_view = cg_state.containers[0].instance_view
+                current_state = (
+                    instance_view.current_state.state
+                    if instance_view is not None
+                    else cg_state.provisioning_state
+                )
+                terminal_states = {"Terminated", "Succeeded", "Failed", 
"Unhealthy"}
+                if current_state not in terminal_states:

Review Comment:
   Removed the pre-defer get_state() check entirely — the operator now defers 
unconditionally after create_or_update(). The trigger's polling loop now 
handles all state checking, and treats instance_view is None as non-terminal 
(keeps polling) except for explicit provisioning failures (Failed/Unhealthy).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to