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/06/28 20:31:42 UTC

[GitHub] [airflow] dstandish commented on a diff in pull request #24716: KubernetesPodOperator can get namespace from hook

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


##########
airflow/providers/cncf/kubernetes/hooks/kubernetes.py:
##########
@@ -363,11 +363,9 @@ def get_custom_object(
     def get_namespace(self) -> Optional[str]:
         """Returns the namespace that defined in the connection"""
         if self.conn_id:
-            connection = self.get_connection(self.conn_id)
-            extras = connection.extra_dejson
-            namespace = extras.get("extra__kubernetes__namespace", "default")
-            return namespace
-        return None
+            return self._get_field('namespace', 'default')

Review Comment:
   this is just an optimization since it uses cached prop `conn_extras` whereas `get_namespace` retrieves the conn in every call



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