Lee-W commented on code in PR #34386:
URL: https://github.com/apache/airflow/pull/34386#discussion_r1345154160


##########
airflow/providers/apache/spark/hooks/spark_submit.py:
##########
@@ -111,6 +111,7 @@ def __init__(
         executor_memory: str | None = None,
         driver_memory: str | None = None,
         keytab: str | None = None,
+        use_krb5ccache: bool = False,

Review Comment:
   Should we make it a keyword-only argument? Also, could we add it to the 
docstring?
   
   ```python
       *,
       use_krb5ccache: bool = False,
   ```



##########
tests/providers/apache/spark/hooks/test_spark_submit.py:
##########
@@ -201,6 +207,22 @@ def test_build_spark_submit_command(self):
             "baz",
         ]
         assert expected_build_cmd == cmd
+        mock_get_env.assert_called_with("KRB5CCNAME")
+
+    @patch("airflow.configuration.conf.get_mandatory_value")
+    def 
test_resolve_spark_submit_env_vars_use_krb5ccache_missing_principal(self, 
mock_get_madantory_value):
+        mock_principle = "airflow"
+        mock_get_madantory_value.return_value = mock_principle
+        hook = SparkSubmitHook(conn_id="spark_yarn_cluster", principal=None, 
use_krb5ccache=True)
+        mock_get_madantory_value.assert_called_with("kerberos", "principal")
+        assert hook._principal == mock_principle
+
+    def 
test_resolve_spark_submit_env_vars_use_krb5ccache_missing_KRB5CCNAME_env(self):
+        hook = SparkSubmitHook(
+            conn_id="spark_yarn_cluster", principal="user/[email protected]", 
use_krb5ccache=True
+        )
+        with pytest.raises(AirflowException):

Review Comment:
   ```suggestion
           with pytest.raises(AirflowException, match="KRB5CCNAME environment 
variable required to use ticket ccache is missing."):
   ```



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