[ 
https://issues.apache.org/jira/browse/AIRFLOW-4526?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17037686#comment-17037686
 ] 

ASF GitHub Bot commented on AIRFLOW-4526:
-----------------------------------------

sarah-johnson commented on pull request #7428: [AIRFLOW-4526] Poll k8s logs to 
avoid problem with kubernetes logs --follow
URL: https://github.com/apache/airflow/pull/7428
 
 
   ---
   Issue link: WILL BE INSERTED BY 
[boring-cyborg](https://github.com/kaxil/boring-cyborg)
   
   Our team has been affected by this issue. After reading through the issue 
history and reviewing the various proposals it seems like this was caused by an 
underlying problem with the kubernetes logs --follow behavior, as was detailed 
by @dorranh on the issue discussion. This change which was [already implemented 
in a fork](https://github.com/discordapp/incubator-airflow/pull/8) by 
@samschlegel works around the problem by polling logs instead of using k8s 
following.
   
   I am a first time contributor but would like to help with seeing through 
this issue being solved in an official Airflow release. I am not sure about the 
test writing aspect - there aren't any tests currently in the 
test_kubernetes_pod_operator for get_logs. Would be glad to follow through with 
writing tests, and/or changing any implementation details, based on your 
feedback or suggestions. Thank you for your consideration.
   
   - [x] Description above provides context of the change
   - [x] Commit message/PR title starts with `[AIRFLOW-NNNN]`. AIRFLOW-NNNN = 
JIRA ID<sup>*</sup>
   - [ ] Unit tests coverage for changes (not needed for documentation changes)
   - [x] Commits follow "[How to write a good git commit 
message](http://chris.beams.io/posts/git-commit/)"
   - [x] Relevant documentation is updated including usage instructions.
   - [x] I will engage committers as explained in [Contribution Workflow 
Example](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#contribution-workflow-example).
   
   <sup>*</sup> For document-only changes commit message can start with 
`[AIRFLOW-XXXX]`.
   
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> KubernetesPodOperator gets stuck in Running state when get_logs is set to 
> True and there is a long gap without logs from pod
> ----------------------------------------------------------------------------------------------------------------------------
>
>                 Key: AIRFLOW-4526
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-4526
>             Project: Apache Airflow
>          Issue Type: Bug
>          Components: operators
>         Environment: Azure Kubernetes Service cluster with Airflow based on 
> puckel/docker-airflow
>            Reporter: Christian Lellmann
>            Priority: Major
>              Labels: kubernetes
>             Fix For: 2.0.0
>
>
> When setting the `get_logs` parameter in the KubernetesPodOperator to True 
> the Operator task get stuck in the Running state if the pod that is run by 
> the task (in_cluster mode) writes some logs and then stops writing logs for a 
> longer time (few minutes) before continuing writing. The continued logging 
> isn't fetched anymore and the pod states aren't checked anymore. So, the 
> completion of the pod isn't recognized and the tasks never finishes.
>  
> Assumption:
> In the `monitor_pod` method of the pod launcher 
> ([https://github.com/apache/airflow/blob/master/airflow/kubernetes/pod_launcher.py#L97])
>  the `read_namespaced_pod_log` method of the kubernetes client get stuck in 
> the `Follow=True` stream 
> ([https://github.com/apache/airflow/blob/master/airflow/kubernetes/pod_launcher.py#L108])
>  because if there is a time without logs from the pod the method doesn't 
> forward the following logs anymore, probably.
> So, the `pod_launcher` doesn't check the pod states later anymore 
> ([https://github.com/apache/airflow/blob/master/airflow/kubernetes/pod_launcher.py#L118])
>  and doesn't recognize the complete state -> the task sticks in Running.
> When disabling the `get_logs` parameter everything works because the log 
> stream is skipped.
>  
> Suggestion:
> Poll the logs actively without the `Follow` parameter set to True in parallel 
> with the pod state checking.
> So, it's possible to fetch the logs without the described connection problem 
> and coincidently check the pod state to be definetly able to recognize the 
> end states of the pods.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to