-
Notifications
You must be signed in to change notification settings - Fork 14.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added "name" and "hostname" to template_fields in KubernetesPodOperator #43601
base: main
Are you sure you want to change the base?
added "name" and "hostname" to template_fields in KubernetesPodOperator #43601
Conversation
providers/src/airflow/providers/cncf/kubernetes/operators/pod.py
Outdated
Show resolved
Hide resolved
providers/src/airflow/providers/cncf/kubernetes/operators/pod.py
Outdated
Show resolved
Hide resolved
"kubernetes_conn_id", | ||
"name", | ||
"hostname", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add tests that cover this change in test_pod.py?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added, thanks!
I see I have some tests failing, setting PR to draft until I fix these. |
The tests seem to fail because some of them mock the I need help here - what is the way to solve this in your opinion? |
@@ -594,6 +596,8 @@ def extract_xcom(self, pod: k8s.V1Pod) -> dict[Any, Any] | None: | |||
|
|||
def execute(self, context: Context): | |||
"""Based on the deferrable parameter runs the pod asynchronously or synchronously.""" | |||
context["task"].name = self._set_name(context["task"].name) # type: ignore[attr-defined] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need to use the context here.
you can just use self.name like this
context["task"].name = self._set_name(context["task"].name) # type: ignore[attr-defined] | |
self.name = self._set_name(self.name) |
Hi,
This PR closes: #43480.
It's a small change, which involves adding the
name
andhostname
to thetemplate_fields
in theKubernetesPodOperator
.I decided to use a different approach from the one suggested by the issue creator.
This was to avoid changing the class API by renaming
self.name
toself.pod_name
.What do you think?