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:40:47 UTC
[GitHub] [airflow] jedcunningham commented on a diff in pull request #24716: KubernetesPodOperator can get namespace from hook
jedcunningham commented on code in PR #24716:
URL: https://github.com/apache/airflow/pull/24716#discussion_r908925966
##########
airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py:
##########
@@ -526,7 +526,7 @@ def build_pod_request_obj(self, context=None):
api_version="v1",
kind="Pod",
metadata=k8s.V1ObjectMeta(
- namespace=self.namespace,
+ namespace=self.namespace or self.hook.get_namespace(),
Review Comment:
Might need to do this at the start of execute instead. Other things (like get_or_create_pod) use the namespace too.
##########
airflow/providers/cncf/kubernetes/hooks/kubernetes.py:
##########
@@ -152,16 +152,16 @@ def conn_extras(self):
extras = {}
return extras
- def _get_field(self, field_name):
+ def _get_field(self, field_name, default=None):
if field_name.startswith('extra_'):
raise ValueError(
f"Got prefixed name {field_name}; please remove the 'extra__kubernetes__' prefix "
f"when using this method."
)
if field_name in self.conn_extras:
- return self.conn_extras[field_name] or None
+ return self.conn_extras[field_name] or default
Review Comment:
I know this is existing code, but using truthy here is unfortunate. A problem for another day though.
--
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