sun2everyone commented on issue #28326:
URL: https://github.com/apache/airflow/issues/28326#issuecomment-2022366729

   Hello. I think ideal solution to this issue is to rewrite code for 
displaying logs on grid view page as it is done on logs page (continious batch 
loading). This is more simple solution I implemented (Airflow 2.4.2):
   ```
   diff --git 
a/lib/python3.8/site-packages/airflow/api_connexion/endpoints/log_endpoint.py 
b/lib/python3.8/site-packages/airflow/api_connexion/endpoints/log_endpoint.py
   index bda0af3..364a48f 100644
   --- 
a/lib/python3.8/site-packages/airflow/api_connexion/endpoints/log_endpoint.py
   +++ 
b/lib/python3.8/site-packages/airflow/api_connexion/endpoints/log_endpoint.py
   @@ -33,7 +33,7 @@
    from airflow.utils.airflow_flask_app import get_airflow_app
    from airflow.utils.log.log_reader import TaskLogReader
    from airflow.utils.session import NEW_SESSION, provide_session
   -
   +from airflow.utils.state import State
   
    @security.requires_access(
        [
   @@ -108,6 +108,8 @@
            token = URLSafeSerializer(key).dumps(metadata)  # type: 
ignore[assignment]
            return logs_schema.dump(LogResponseObject(continuation_token=token, 
content=logs))
        # text/plain. Stream
   -    logs = task_log_reader.read_log_stream(ti, task_try_number, metadata)
   -
   +    if ti.state not in State.running:
   +        logs = task_log_reader.read_log_stream(ti, task_try_number, 
metadata)
   +    else:
   +        logs = {"Task is still running, logs in grid view not available."}
        return Response(logs, headers={"Content-Type": return_type})
   ```
   It just disables displaying logs in grid view if task state is 'Running'. 
Works in production for more than a year, without any problem.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to