hunnguye commented on code in PR #71949:
URL: https://github.com/apache/airflow/pull/71949#discussion_r3887749823
##########
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:
As I understand, the master endpoint is taken from connection.host
https://github.com/apache/airflow/blob/166a1ba1eecf969ed33ad17dd1232b20d7ce5aea/providers/apache/spark/src/airflow/providers/apache/spark/hooks/spark_submit.py#L419-L424
And the whole hook is assuming it is a single host entry:
for example:
https://github.com/apache/airflow/blob/166a1ba1eecf969ed33ad17dd1232b20d7ce5aea/providers/apache/spark/src/airflow/providers/apache/spark/hooks/spark_submit.py#L427
https://github.com/apache/airflow/blob/166a1ba1eecf969ed33ad17dd1232b20d7ce5aea/providers/apache/spark/src/airflow/providers/apache/spark/hooks/spark_submit.py#L561
And the og build_track_driver_command as well (which we will fix in this PR)
https://github.com/apache/airflow/blob/166a1ba1eecf969ed33ad17dd1232b20d7ce5aea/providers/apache/spark/src/airflow/providers/apache/spark/hooks/spark_submit.py#L679
I could fix my code to handle single and multi master endpoints as you
requested, but this feels inconsistent with the rest of the current code and
could confuse other contributors.
I'd rather suggest to add a comment, and change this in a later PR to handle
comma separated master endpoints (and therefore rest endpoints).
--
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]