docker-airflow: "Failed to fetch log file from worker" when running LocalExecutor
I’m seeing this in the webinterface when trying to access the logs of a task, but only when running LocalExecutor - could this be a misconfiguration?
*** Log file isn't local.
*** Fetching here: http://33d456e47018:8793/log/g_pipelines/rawlogs_pipeline/2016-10-24T05:30:00
*** Failed to fetch log file from worker.
*** Reading remote logs...
*** Unsupported remote log location.
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 72
- Comments: 70 (11 by maintainers)
I took a different approach to solve this, which was to declare
/usr/local/airflow/logsas a volume in my Dockerfile extending this image, and then to have my webserver container use the volumes from the scheduler. This allows having just one process per container. Note that the directory has to be created before declaring it as a volume otherwise it will be owned by root and the scheduler won’t be able to write to it.Posted in Airflow’s chat:
I had to add 8793 to the ports for the worker to expose the port, then I can navigate to the logs at http://[mydockerhost]:8793/log/[dag_id]/[task_id]/[execution_date]
Does anyone have a complete workaround to this problem ? I think I have the same problem, but I’m not able to make it work 😕
I made the volume sharing worked by using volumes: - ./airflow-logs:/usr/local/airflow/logs
and we have to make sure ./airflow-logs is owned by a user airflow on the host chown airflow: ./airflow-logs
restart the service with docker-compose
My workaround, you could call it solution, is to mount a named-volume between scheduler, worker and webserver for the logfiles so that they appear “local” to the webserver. I am using the celery-executor.
I had same problem here (airflow v1.8.0). When I have used UI or command
trigger_dagto run my dag :Nothing was happening, logs in UI shows :
Airflow even doesn’t created folders for log files.
But it works if I run command with
backfillas suggested by @licryle .same here, I can’t see logs when launching from the UI, nor with airflow trigger_dag, however it seems to work when starting with airflow backfill.
So here’s the issue as I see it:
The worker creates a
/etc/hostsentry for its hostname:But the webserver does not:
The assumption by airflow must be that these two processes are executing on the same host. In a containerized env, this is not the case. Therefore the webserver container needs a hosts mapping to the worker(s).
@omegagi it’s the regular log files produced for each task in the dag. The good thing of that setup is all logs are shared by all docker container and also persisted on the host machine. When docker-airflow restarted, we still have the previous logs available
Another possible solution just found it incubator-airflow-dev mailing list, and i quote (thread name: Fixing logging for Airflow inside Docker):
@puckel It seems from your desktop that your image correctly resolves the worker IP from its celery identification.
*** Fetching here: https://THEWORKERID/log/...While this is failing for me, and according to @crorella and @licryle this behavior is related to tasks started from the UI only. Can you confirm this?
If that’s the case, I’m going to open this issue in the Apache Airflow issue tracker instead and we could close this one, since it’s very likely not a problem with the docker setup but with Airflow itself.
We are running airflow workers in docker containers on separate machines and had the exact same problem as in the initial post:
For us, setting the
network_modetohostfor the airflow worker containers causes that they can get the hostname of the machine they are running on. The hostname will be reported to celery and airflow will use this name to create the log URL, fixing our problem.Just going to put this here since I’ve spent a couple hours troubleshooting this over the past few months and have given up multiple times. I’m running docker-airflow (w/ Celery executor) behind a corporate proxy and had HTTP_PROXY environment variables set. This was redirecting the log fetching calls to a proxy authentication web login page.
The fix was to simply add
- NO_PROXY=*to theenvironment:section of thewebserverservice in my docker compose yml.Hi,
I’ve fixed the problem in branch v1.8.0 (commit d4636f9). Airflow try to fetch logs on port tcp/8793 which is created by airflow worker. If using LocalExecutor, the sheduler and the webserver must be on the same host.
@manur @AdimUser What if there are multiple docker containers running in the same host machine at the port 8793 ?
I passed the
docker parameter to docker run for the worker. so it will set the hostname for the docker instance.
@tkaymak @villasv
By setting the network to be that of the host, I was able to work around this. This forces docker to assign the same hostname to containers as the underlying host.
I now see the container hostnames for task logs reflect the underlying hostnames:
For what it’s worth, I am also seeing the message below when I triggered a DAG manually through the UI using the LocalExecutor.
In addition the task seemed to be stuck in a running state.
When I changed from
schedule_interval="@once"and manually triggering the dag toschedule_interval="* * * * *"and letting the scheduler pick it up the logs were visible as expected and the job ran as expected.I had been hoping to use something like a one-time DAG to load connections to bootstrap a container for DAG development.
@sdikby No, it’s not fixing this issue.
The problem only occurs when using
load_examples = True, I’ve tested with tuto.py dag withLOAD_EX=nin the compose file and the webserver have no problem to access logs on workers@EBazarov Do you use a custom dag or examples ?