You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2022/10/26 20:54:36 UTC

[GitHub] [airflow] dstandish commented on a diff in pull request #27202: Add deprecation warning re unset namespace in k8s hook

dstandish commented on code in PR #27202:
URL: https://github.com/apache/airflow/pull/27202#discussion_r1006178099


##########
airflow/providers/cncf/kubernetes/hooks/kubernetes.py:
##########
@@ -319,9 +319,32 @@ def get_custom_object(
             raise AirflowException(f"Exception when calling -> get_custom_object: {e}\n")
 
     def get_namespace(self) -> str | None:
-        """Returns the namespace that defined in the connection"""
+        """
+        Returns the namespace defined in the connection or 'default'.
+
+        TODO: in provider version 6.0, return None when namespace not defined in connection
+        """
+        namespace = self._get_namespace()
+        if self.conn_id and not namespace:
+            warnings.warn(
+                "Airflow connection defined but namespace is not set; 'default'.  In "
+                "cncf.kubernetes provider version 6.0 we will return None when namespace is "
+                "not defined in the connection so that it's clear whether user intends 'default' or "
+                "whether namespace is unset (which is required in order to apply precedence logic in "
+                "KubernetesPodOperator.",

Review Comment:
   i _always_ forget to close parentheses



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org