-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Description
Apache Airflow version:
Airflow 2.1.0
Environment:
- OS (e.g. from /etc/os-release): Ubuntu 20
- Kernel (e.g.
uname -a): 5.4.0-48- - Install tools: pip
- Others: python3.8, use celeryexcutor, 3 worker: hadoop03,hadoop04,hadoop05, webserver:hadoop03
What happened:
When a task retry a lot of times, some log show error:
*** Log file does not exist: /home/hadoop/airflow/logs/retry4/print_date/2021-06-14T00:00:00+00:00/10.log
*** Fetching from: http://hadoop05:8793/log/retry4/print_date/2021-06-14T00:00:00+00:00/10.log
*** Failed to fetch log file from worker. 404 Client Error: NOT FOUND for url: http://hadoop05:8793/log/retry4/print_date/2021-06-14T00:00:00+00:00/10.log
It is because the log retry4/print_date/2021-06-14T00:00:00+00:00/10.log is not in hadoop05 and it is in hadoop04. we can find log file /home/hadoop/airflow/logs/retry4/print_date/2021-06-14T00:00:00+00:00/10.log in hadoop04.
As we can see, the task's latest log is in hadoop05. I guess webserver firstly search log from local host, secondly it will search host from the latest hostname nomatter if other previous logs is in the latest hostname.
We can get the task's laest log in hadoop05.


We can also get previous log in webserver host hadoop03.

But We can not get previous log which is not in hadoop05 and hadoop03(webserver host). Because webserver try to search log from hadop05 but not hadoop04 which the log is really in.

What you expected to happen:
Webserver should try to get log from ther right worker server but not hadoop05 which the latest log is in.
How to reproduce it:
You can try these dags in a airflow cluster that has more than 3 celery worker node.
#
# 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.
"""
### Tutorial Documentation
Documentation that goes along with the Airflow tutorial located
[here](https://airflow.apache.org/tutorial.html)
"""
# [START tutorial]
# [START import_module]
from datetime import timedelta
from textwrap import dedent
# The DAG object; we'll need this to instantiate a DAG
from airflow.models import DAG, Variable
from airflow.operators.bash_operator import BashOperator
# Operators; we need this to operate!
from airflow.utils.dates import days_ago
# [END import_module]
# [START default_args]
# These args will get passed on to each operator
# You can override them on a per-task basis during operator initialization
default_args = {
'owner': 'airflow',
'depends_on_past': False,
'email': ['airflow@example.com'],
'email_on_failure': False,
'email_on_retry': False,
'retries': 10,
'retry_delay': timedelta(minutes=1),
# 'queue': 'bash_queue',
# 'pool': 'backfill',
# 'priority_weight': 10,
# 'end_date': datetime(2016, 1, 1),
# 'wait_for_downstream': False,
# 'dag': dag,
# 'sla': timedelta(hours=2),
# 'execution_timeout': timedelta(seconds=300),
# 'on_failure_callback': some_function,
# 'on_success_callback': some_other_function,
# 'on_retry_callback': another_function,
# 'sla_miss_callback': yet_another_function,
# 'trigger_rule': 'all_success'
}
# [END default_args]
# [START instantiate_dag]
with DAG(
'retry4',
default_args=default_args,
description='A simple tutorial DAG',
schedule_interval=timedelta(days=1),
start_date=days_ago(2),
tags=['example'],
) as dag:
# [END instantiate_dag]
# t1, t2 and t3 are examples of tasks created by instantiating operators
# [START basic_task]
t1 = BashOperator(
task_id='print_date',
bash_command='exit 1',
)
t2 = BashOperator(
task_id='sleep',
depends_on_past=False,
bash_command='sleep 5',
retries=3,
)
# [END basic_task]
# [START documentation]
t1.doc_md = dedent(
"""\
#### Task Documentation
You can document your task using the attributes `doc_md` (markdown),
`doc` (plain text), `doc_rst`, `doc_json`, `doc_yaml` which gets
rendered in the UI's Task Instance Details page.

"""
)
dag.doc_md = __doc__ # providing that you have a docstring at the beggining of the DAG
dag.doc_md = """
This is a documentation placed anywhere
""" # otherwise, type it like this
# [END documentation]
# [START jinja_template]
templated_command = dedent(
"""
{% for i in range(5) %}
echo "{{ ds }}"
echo "{{ macros.ds_add(ds, 7)}}"
echo "{{ params.my_param }}"
{% endfor %}
"""
)
t3 = BashOperator(
task_id='templated',
depends_on_past=False,
bash_command=templated_command,
params={'my_param': 'Parameter I passed in'},
)
# [END jinja_template]
t1 >> [t2, t3]
# [END tutorial]
Anything else we need to know:
I have test in airflow2.0.2 and airflow1.10.12, this bug always exists.