You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "MaksYermak (via GitHub)" <gi...@apache.org> on 2024/07/16 11:53:53 UTC
[PR] Fix 'do_xcom_push' and 'get_logs' functionality for KubernetesJobOperator [airflow]
MaksYermak opened a new pull request, #40814:
URL: https://github.com/apache/airflow/pull/40814
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
In this PR I have fixed usage for `do_xcom_push` and `get_logs` functionality for `KubernetesJobOperator` in deferrable and non-deferrable modes.
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
--
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
Re: [PR] Fix 'do_xcom_push' and 'get_logs' functionality for KubernetesJobOperator [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #40814:
URL: https://github.com/apache/airflow/pull/40814
--
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
Re: [PR] Fix 'do_xcom_push' and 'get_logs' functionality for KubernetesJobOperator [airflow]
Posted by "MaksYermak (via GitHub)" <gi...@apache.org>.
MaksYermak commented on code in PR #40814:
URL: https://github.com/apache/airflow/pull/40814#discussion_r2135292464
##########
airflow/providers/cncf/kubernetes/operators/job.py:
##########
@@ -159,34 +166,59 @@ def execute(self, context: Context):
ti.xcom_push(key="job_name", value=self.job.metadata.name)
ti.xcom_push(key="job_namespace", value=self.job.metadata.namespace)
+ if self.pod is None:
+ self.pod = self.get_or_create_pod( # must set `self.pod` for `on_kill`
+ pod_request_obj=self.pod_request_obj,
+ context=context,
+ )
Review Comment:
Hello @steinwaywhw,
It's a known issue https://github.com/apache/airflow/issues/44994 and the fix was already prepared by this PR https://github.com/apache/airflow/pull/49899
--
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
Re: [PR] Fix 'do_xcom_push' and 'get_logs' functionality for KubernetesJobOperator [airflow]
Posted by "NilsIrl (via GitHub)" <gi...@apache.org>.
NilsIrl commented on code in PR #40814:
URL: https://github.com/apache/airflow/pull/40814#discussion_r1828343415
##########
airflow/providers/cncf/kubernetes/operators/job.py:
##########
@@ -159,34 +166,59 @@ def execute(self, context: Context):
ti.xcom_push(key="job_name", value=self.job.metadata.name)
ti.xcom_push(key="job_namespace", value=self.job.metadata.namespace)
+ if self.pod is None:
+ self.pod = self.get_or_create_pod( # must set `self.pod` for `on_kill`
+ pod_request_obj=self.pod_request_obj,
+ context=context,
+ )
Review Comment:
How does this work if the pod wasn't already created by the time this is reached? Won't 2 pods eventually get created?
##########
airflow/providers/cncf/kubernetes/operators/job.py:
##########
@@ -159,34 +166,59 @@ def execute(self, context: Context):
ti.xcom_push(key="job_name", value=self.job.metadata.name)
ti.xcom_push(key="job_namespace", value=self.job.metadata.namespace)
+ if self.pod is None:
+ self.pod = self.get_or_create_pod( # must set `self.pod` for `on_kill`
+ pod_request_obj=self.pod_request_obj,
+ context=context,
+ )
Review Comment:
How does this work if the pod wasn't already created by the time this is reached? Won't 2 pods eventually get created (when the job eventually creates the pod)?
--
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
Re: [PR] Fix 'do_xcom_push' and 'get_logs' functionality for KubernetesJobOperator [airflow]
Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on code in PR #40814:
URL: https://github.com/apache/airflow/pull/40814#discussion_r2135075380
##########
airflow/providers/cncf/kubernetes/operators/job.py:
##########
@@ -159,34 +166,59 @@ def execute(self, context: Context):
ti.xcom_push(key="job_name", value=self.job.metadata.name)
ti.xcom_push(key="job_namespace", value=self.job.metadata.namespace)
+ if self.pod is None:
+ self.pod = self.get_or_create_pod( # must set `self.pod` for `on_kill`
+ pod_request_obj=self.pod_request_obj,
+ context=context,
+ )
Review Comment:
@steinwaywhw can you explain your problem more? Would you like to take a stab at fixing it?
--
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
Re: [PR] Fix 'do_xcom_push' and 'get_logs' functionality for KubernetesJobOperator [airflow]
Posted by "VladaZakharova (via GitHub)" <gi...@apache.org>.
VladaZakharova commented on PR #40814:
URL: https://github.com/apache/airflow/pull/40814#issuecomment-2262588658
Hi @romsharon98 and @amoghrajesh ! can you please check changes here? Thanks!
--
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
Re: [PR] Fix 'do_xcom_push' and 'get_logs' functionality for KubernetesJobOperator [airflow]
Posted by "NilsIrl (via GitHub)" <gi...@apache.org>.
NilsIrl commented on code in PR #40814:
URL: https://github.com/apache/airflow/pull/40814#discussion_r1828343415
##########
airflow/providers/cncf/kubernetes/operators/job.py:
##########
@@ -159,34 +166,59 @@ def execute(self, context: Context):
ti.xcom_push(key="job_name", value=self.job.metadata.name)
ti.xcom_push(key="job_namespace", value=self.job.metadata.namespace)
+ if self.pod is None:
+ self.pod = self.get_or_create_pod( # must set `self.pod` for `on_kill`
+ pod_request_obj=self.pod_request_obj,
+ context=context,
+ )
Review Comment:
Doesn't this defeat the point of using a job if a pod is created anyway? Also doesn't this mean 2 pods are now created (1 from the job and this pod that's also manually created)?
--
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
Re: [PR] Fix 'do_xcom_push' and 'get_logs' functionality for KubernetesJobOperator [airflow]
Posted by "VladaZakharova (via GitHub)" <gi...@apache.org>.
VladaZakharova commented on PR #40814:
URL: https://github.com/apache/airflow/pull/40814#issuecomment-2304205264
Hi @romsharon98, @amoghrajesh @potiuk @eladkal !
Can you please check changes here?
--
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
Re: [PR] Fix 'do_xcom_push' and 'get_logs' functionality for KubernetesJobOperator [airflow]
Posted by "steinwaywhw (via GitHub)" <gi...@apache.org>.
steinwaywhw commented on code in PR #40814:
URL: https://github.com/apache/airflow/pull/40814#discussion_r2134339665
##########
airflow/providers/cncf/kubernetes/operators/job.py:
##########
@@ -159,34 +166,59 @@ def execute(self, context: Context):
ti.xcom_push(key="job_name", value=self.job.metadata.name)
ti.xcom_push(key="job_namespace", value=self.job.metadata.namespace)
+ if self.pod is None:
+ self.pod = self.get_or_create_pod( # must set `self.pod` for `on_kill`
+ pod_request_obj=self.pod_request_obj,
+ context=context,
+ )
Review Comment:
I have the same question. I thought the K8s Job will manage the pod creations, why would we need creating the pod manually again? I'm actually running into bugs where I set parallelism to more than 1 and this line triggers self.find_pods() which triggers https://github.com/apache/airflow/blob/56fbe90a8d0b56558c02d75f4ac5852e041cb058/providers/cncf/kubernetes/src/airflow/providers/cncf/kubernetes/operators/pod.py#L563
--
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