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/07/14 11:07:56 UTC

[GitHub] [airflow] ryantam626 opened a new pull request, #25055: Wait for xcom sidecar container to start before sidecar exec

ryantam626 opened a new pull request, #25055:
URL: https://github.com/apache/airflow/pull/25055

   According to k8s's docs on pod phase [1], "Running" state means "The Pod has been bound to a node,
   and all of the containers have been created. At least one container is still running,
   or is in the process of starting or restarting.".
   
   There is no guarantee that the xcom sidecar container will have been
   running by the time the `extract_com` is used by KPO's `execute` -
   meaning if the base container has completed before the xcom sidecar
   container is running, the entire operator fails because you cannot exec
   against a non-running container.
   
   Fix is to wait for the xcom sidecar container to be in the running state
   before we exec against it, which this commit implements.
   
   [1] - https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/#pod-phase
   [2] - https://github.com/schattian/airflow/blob/86171ff43f8977021708cfa241da64f96c4c15e2/airflow/providers/cncf/kubernetes/operators/kubernetes_pod.py#L398
   
   <!--
   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/
   -->
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.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+Improvements+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


[GitHub] [airflow] boring-cyborg[bot] commented on pull request #25055: Wait for xcom sidecar container to start before sidecar exec

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on PR #25055:
URL: https://github.com/apache/airflow/pull/25055#issuecomment-1184312984

   Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst)
   Here are some useful points:
   - Pay attention to the quality of your code (flake8, mypy and type annotations). Our [pre-commits]( https://github.com/apache/airflow/blob/main/STATIC_CODE_CHECKS.rst#prerequisites-for-pre-commit-hooks) will help you with that.
   - In case of a new feature add useful documentation (in docstrings or in `docs/` directory). Adding a new operator? Check this short [guide](https://github.com/apache/airflow/blob/main/docs/apache-airflow/howto/custom-operator.rst) Consider adding an example DAG that shows how users should use it.
   - Consider using [Breeze environment](https://github.com/apache/airflow/blob/main/BREEZE.rst) for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
   - Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
   - Please follow [ASF Code of Conduct](https://www.apache.org/foundation/policies/conduct) for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
   - Be sure to read the [Airflow Coding style]( https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#coding-style-and-best-practices).
   Apache Airflow is a community-driven project and together we are making it better 🚀.
   In case of doubts contact the developers at:
   Mailing List: dev@airflow.apache.org
   Slack: https://s.apache.org/airflow-slack
   


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


[GitHub] [airflow] boring-cyborg[bot] commented on pull request #25055: Wait for xcom sidecar container to start before sidecar exec

Posted by GitBox <gi...@apache.org>.
boring-cyborg[bot] commented on PR #25055:
URL: https://github.com/apache/airflow/pull/25055#issuecomment-1221629322

   Awesome work, congrats on your first merged pull request!
   


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


[GitHub] [airflow] potiuk commented on pull request #25055: Wait for xcom sidecar container to start before sidecar exec

Posted by GitBox <gi...@apache.org>.
potiuk commented on PR #25055:
URL: https://github.com/apache/airflow/pull/25055#issuecomment-1221629308

   This looks cool - @dstandish you might take a look when you are back but this one looks rather straightforward. Merging.


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


[GitHub] [airflow] potiuk commented on pull request #25055: Wait for xcom sidecar container to start before sidecar exec

Posted by GitBox <gi...@apache.org>.
potiuk commented on PR #25055:
URL: https://github.com/apache/airflow/pull/25055#issuecomment-1187687623

   The test I was thinking was more along the lines of actually having a k8s cluster that can reproduce the behaviour of xcom container not started when base container has completed, and check that xcom extraction was successful.
   
   Running them on "integration" level is expensive and we alredy have some of those tests that take far too much time of our CI :)


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


[GitHub] [airflow] potiuk commented on pull request #25055: Wait for xcom sidecar container to start before sidecar exec

Posted by GitBox <gi...@apache.org>.
potiuk commented on PR #25055:
URL: https://github.com/apache/airflow/pull/25055#issuecomment-1184355583

   Use mocking. see similar tests in test_pod_manager.py


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


[GitHub] [airflow] dstandish commented on pull request #25055: Wait for xcom sidecar container to start before sidecar exec

Posted by GitBox <gi...@apache.org>.
dstandish commented on PR #25055:
URL: https://github.com/apache/airflow/pull/25055#issuecomment-1187710420

   i'll have a look


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


[GitHub] [airflow] ryantam626 commented on pull request #25055: Wait for xcom sidecar container to start before sidecar exec

Posted by GitBox <gi...@apache.org>.
ryantam626 commented on PR #25055:
URL: https://github.com/apache/airflow/pull/25055#issuecomment-1184315849

   Not exactly sure how I can properly introduce a failing test and then make it pass here, would like some guidance on this.


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


[GitHub] [airflow] dstandish commented on a diff in pull request #25055: Wait for xcom sidecar container to start before sidecar exec

Posted by GitBox <gi...@apache.org>.
dstandish commented on code in PR #25055:
URL: https://github.com/apache/airflow/pull/25055#discussion_r923580233


##########
airflow/providers/cncf/kubernetes/utils/pod_manager.py:
##########
@@ -354,8 +354,19 @@ def read_pod(self, pod: V1Pod) -> V1Pod:
         except BaseHTTPError as e:
             raise AirflowException(f'There was an error reading the kubernetes API: {e}')
 
+    def await_xcom_sidecar_container_start(self, pod: V1Pod) -> None:
+        while True:
+            self.log.info("Checking if xcom sidecar container is started.")
+            if self.container_is_running(pod, PodDefaults.SIDECAR_CONTAINER_NAME):
+                self.log.warning("The xcom sidecar container is started.")

Review Comment:
   ```suggestion
   ```
   
   i don't think we need to log anything here.  if anything it should be info.



##########
airflow/providers/cncf/kubernetes/utils/pod_manager.py:
##########
@@ -354,8 +354,19 @@ def read_pod(self, pod: V1Pod) -> V1Pod:
         except BaseHTTPError as e:
             raise AirflowException(f'There was an error reading the kubernetes API: {e}')
 
+    def await_xcom_sidecar_container_start(self, pod: V1Pod) -> None:
+        while True:
+            self.log.info("Checking if xcom sidecar container is started.")
+            if self.container_is_running(pod, PodDefaults.SIDECAR_CONTAINER_NAME):
+                self.log.warning("The xcom sidecar container is started.")
+                break
+            self.log.warning("The xcom sidecar container is not yet started.")

Review Comment:
   thinking maybe this we should only log _once_ -- the first time it has to wait, and not every loop.  wdyt?
   
   



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


[GitHub] [airflow] potiuk merged pull request #25055: Wait for xcom sidecar container to start before sidecar exec

Posted by GitBox <gi...@apache.org>.
potiuk merged PR #25055:
URL: https://github.com/apache/airflow/pull/25055


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


[GitHub] [airflow] eladkal commented on pull request #25055: Wait for xcom sidecar container to start before sidecar exec

Posted by GitBox <gi...@apache.org>.
eladkal commented on PR #25055:
URL: https://github.com/apache/airflow/pull/25055#issuecomment-1209570060

   @ryantam626 are you still working on this PR? 


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


[GitHub] [airflow] eladkal commented on pull request #25055: Wait for xcom sidecar container to start before sidecar exec

Posted by GitBox <gi...@apache.org>.
eladkal commented on PR #25055:
URL: https://github.com/apache/airflow/pull/25055#issuecomment-1209688284

   Static cheks failed :(


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


[GitHub] [airflow] potiuk commented on pull request #25055: Wait for xcom sidecar container to start before sidecar exec

Posted by GitBox <gi...@apache.org>.
potiuk commented on PR #25055:
URL: https://github.com/apache/airflow/pull/25055#issuecomment-1187688092

   Anyone else ?


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


[GitHub] [airflow] ryantam626 commented on pull request #25055: Wait for xcom sidecar container to start before sidecar exec

Posted by GitBox <gi...@apache.org>.
ryantam626 commented on PR #25055:
URL: https://github.com/apache/airflow/pull/25055#issuecomment-1211005179

   @eladkal all green now, sorry for the wait.
   
   And thanks to whoever approved the start of CI for me :pray: 


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


[GitHub] [airflow] ryantam626 commented on pull request #25055: Wait for xcom sidecar container to start before sidecar exec

Posted by GitBox <gi...@apache.org>.
ryantam626 commented on PR #25055:
URL: https://github.com/apache/airflow/pull/25055#issuecomment-1209581597

   Oh sorry, I wasn't aware the WDYTs are directed at me.
   
   I will work on the changes @dstandish suggested now.


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


[GitHub] [airflow] potiuk commented on pull request #25055: Wait for xcom sidecar container to start before sidecar exec

Posted by GitBox <gi...@apache.org>.
potiuk commented on PR #25055:
URL: https://github.com/apache/airflow/pull/25055#issuecomment-1186106919

   LGTM. @jedcunningham @dstandish WDYT?


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


[GitHub] [airflow] dstandish commented on a diff in pull request #25055: Wait for xcom sidecar container to start before sidecar exec

Posted by GitBox <gi...@apache.org>.
dstandish commented on code in PR #25055:
URL: https://github.com/apache/airflow/pull/25055#discussion_r923587572


##########
airflow/providers/cncf/kubernetes/utils/pod_manager.py:
##########
@@ -354,8 +354,19 @@ def read_pod(self, pod: V1Pod) -> V1Pod:
         except BaseHTTPError as e:
             raise AirflowException(f'There was an error reading the kubernetes API: {e}')
 
+    def await_xcom_sidecar_container_start(self, pod: V1Pod) -> None:
+        while True:
+            self.log.info("Checking if xcom sidecar container is started.")
+            if self.container_is_running(pod, PodDefaults.SIDECAR_CONTAINER_NAME):
+                self.log.warning("The xcom sidecar container is started.")
+                break
+            self.log.warning("The xcom sidecar container is not yet started.")
+            time.sleep(1)
+
     def extract_xcom(self, pod: V1Pod) -> str:
         """Retrieves XCom value and kills xcom sidecar container"""
+        self.await_xcom_sidecar_container_start(pod)

Review Comment:
   i would not put this in `extract_xcom` -- i think it's better if `extract_xcom` does not wait, but just extracts; it can be called independently in KPO -- WDYT?



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