aaron-y-chen commented on code in PR #71949:
URL: https://github.com/apache/airflow/pull/71949#discussion_r3885487329


##########
providers/apache/spark/src/airflow/providers/apache/spark/hooks/spark_submit.py:
##########
@@ -457,6 +458,16 @@ def _resolve_connection(self) -> dict[str, Any]:
                     conn_data["keytab"] = 
self._create_keytab_path_from_base64_keytab(
                         base64_keytab, conn_data["principal"]
                     )
+            # Construct the Standalone Restendpoint
+            if (
+                conn.conn_type == "spark"
+                and conn_data["master"].startswith("spark://")
+                and conn_data["deploy_mode"] == "cluster"
+            ):
+                host = conn_data["master"].replace("spark://", "").strip()
+                conn_data["rest_endpoint"] = (
+                    
f"{conn_data['rest_scheme']}://{host.split(':')[0]}:{conn_data['rest_port']}"

Review Comment:
   If `master="spark://m1:7077,m2:7077"`, then `rest_endpoint` will become 
`"http://m1:6066"`, which doesn't seem to work as expected.
   
   Please fix it and add a regression test for this case.



##########
providers/apache/spark/src/airflow/providers/apache/spark/hooks/spark_submit.py:
##########
@@ -1296,17 +1306,30 @@ def _build_spark_driver_kill_command(self) -> list[str]:
 
         :return: full command to kill a driver
         """
-        # Assume that spark-submit is present in the path to the executing user
-        connection_cmd = [self._connection["spark_binary"]]
+        curl_max_wait_time = 30
+        if self._connection["rest_endpoint"]:
+            spark_host = self._connection["rest_endpoint"]
+            connection_cmd = [
+                "/usr/bin/curl",
+                "--max-time",
+                str(curl_max_wait_time),
+                "-X",
+                "POST",
+                f"{spark_host}/v1/submissions/kill/{self._driver_id}",
+            ]
+            self.log.info(connection_cmd)

Review Comment:
   nit: maybe we should use debug level log here.



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