nailo2c commented on code in PR #65991:
URL: https://github.com/apache/airflow/pull/65991#discussion_r3213995034


##########
providers/apache/spark/src/airflow/providers/apache/spark/hooks/spark_submit.py:
##########
@@ -704,6 +753,96 @@ def _process_spark_submit_log(self, itr: Iterator[Any]) -> 
None:
 
             self.log.info(line)
 
+    def _track_yarn_application(self, application_id: str) -> None:
+        """Poll ``yarn application -status <id>`` until a final state is 
reached."""
+        self.log.info(
+            "Tracking YARN application %s via 'yarn application -status' 
polling",
+            application_id,
+        )
+        poll_interval = max(self._status_poll_interval, 1)
+        # Tolerate transient `yarn application -status` failures (RM hiccup, 
network
+        # blip, CLI timeout) the same way `_start_driver_status_tracking` does 
for
+        # spark standalone — only give up after this many consecutive failures.
+        consecutive_failures = 0
+        max_consecutive_failures = 10
+        while True:
+            self.log.debug("Polling: yarn application -status %s", 
application_id)
+            try:
+                final_status = 
self._query_yarn_application_final_status(application_id)
+            except RuntimeError as exc:
+                consecutive_failures += 1
+                if consecutive_failures > max_consecutive_failures:
+                    raise RuntimeError(
+                        f"Giving up tracking YARN application {application_id} 
after "
+                        f"{max_consecutive_failures} consecutive `yarn 
application -status` "
+                        f"failures. Last error: {exc}"
+                    )
+                self.log.warning(
+                    "Transient `yarn application -status` failure (%d/%d): %s",
+                    consecutive_failures,
+                    max_consecutive_failures,
+                    exc,
+                )
+                time.sleep(poll_interval)
+                continue
+            consecutive_failures = 0
+            if final_status == self._YARN_FINAL_SUCCESS:
+                self.log.info("YARN application %s finished with SUCCEEDED", 
application_id)
+                return
+            if final_status in self._YARN_FINAL_FAILURES:
+                raise RuntimeError(
+                    f"YARN application {application_id} ended with final 
status: {final_status}"
+                )

Review Comment:
   I don't think we should apply this. The community has decided to stop adding 
new direct `raise AirflowException` usages.
   
   Ref: 
https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#don-t-raise-airflowexception-directly



-- 
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