docker-airflow icon indicating copy to clipboard operation
docker-airflow copied to clipboard

Error accessing worker logs in kubernetes

Open chiju opened this issue 7 years ago • 10 comments

Hi, I am getting below error in airlfow UI after installing airflow in minikube. worker, scheduler, webserver are all in different pods *** Log file does not exist: /usr/local/airflow/logs/my_first_dag/print_goodbye/2019-07-30T02:00:00+00:00/1.log *** Fetching from: http://worker-74684c5885-bkhkh:8793/log/my_first_dag/print_goodbye/2019-07-30T02:00:00+00:00/1.log *** Failed to fetch log file from worker. HTTPConnectionPool(host='worker-74684c5885-bkhkh', port=8793): Max retries exceeded with url: /log/my_first_dag/print_goodbye/2019-07-30T02:00:00+00:00/1.log (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fc1e98a99b0>: Failed to establish a new connection: [Errno -2] Name or service not known',)) (edited) Please help on this.

chiju avatar Aug 01 '19 05:08 chiju

Are you using the KubernetesExecutor? If so, this is because the workers are launched as pods and deleted afterward. Therefore, there is no worker to retrieve the log from. A simple fix is to enable S3 logging and send your logs to S3. You can also setup a deletion policy that controls how long S3 keeps your logs.

dustinschultz avatar Aug 05 '19 19:08 dustinschultz

Hi @dustinschultz, thanks for the response, but I am installing airflow in kubernetes with celery executer and not kubernetes executer, also now the error is not showing after changing the worker deployment to statefullset

chiju avatar Aug 06 '19 05:08 chiju

@dustinschultz II was wondering if you could give me a hand? I am getting that same err that was posted above, but I am using the KubernetesExectuor.

I used to run 4 airflow pods (webserver, scheduler, flower, worker) and now I'm trying to run on one pod (just the webserver). I am able to start my job that uses the KubernetesExecutor, and the dummy start task starts up, but my jobs fail on the next task due to basically the same err msg as above. I'm really looking to try this out w/out S3 or external logging. I'm think that I've set up the logging to use a pv-claim ... any thoughts?

ketikat avatar Sep 05 '19 16:09 ketikat

@ketikat Hi. Yep, you're on the right track. See the KuberneteExecutor doc:

# This prop may optionally be set for PV Claims and is used to write logs
 self.logs_volume_claim = conf.get(self.kubernetes_section, 'logs_volume_claim')

Also, you shouldn't need a flower pod unless you're also using Celery workers. The same goes for the dedicated worker pod as you would only have a dedicated pod if you were using Celery. KubernetesExecutor has a bunch of config to setup the worker pod that it launches (and subsequently deletes upon shutdown).

dustinschultz avatar Sep 05 '19 17:09 dustinschultz

@dustinschultz awesome thanks! Yeah, I forgot to mention we ditched flower and celery entirely.

Also, if you feel like shedding more insight: another issue I'm having is that I used to use Redis to check job statuses, now that I've ditched Celery and Redis altogether, I need to figure out how to check if things are running and to check the results of certain tasks in order to branch_op accordingly. Do you know how'd id be able to achieve something like that w/ out Redis? or do you recommend bringing Redis back to work in conjunction w the KuEx?

ketikat avatar Sep 05 '19 17:09 ketikat

@ketikat I have been using celery with redis as a broker for past 6 months. Its working without a hitch.

@chiju Regarding your issue, I have encountered the same issue multiple times, and it was mainly because of not allocating enough memory to the container. Try playing around with resource requests/limits.

mrigesh avatar Sep 12 '19 11:09 mrigesh

@mrigesh If I remember it correctly, it got resolved by changing the service for worker deployment to stateless, I am new to kubernetes. May be there is multiple solution for this issue, anyway thanks for the answer

chiju avatar Sep 13 '19 06:09 chiju

@dustinschultz @chiju I have the same issue except I deployed everything on AWS ECS (4 services, each runs 1 task definition: webserver, scheduler, flower, worker). I'm using the ECSOperator in my DAG and I couldn't get the log because of this error.

zachliu avatar Sep 14 '19 06:09 zachliu

It works well on ECS when remote_logging is switched to True and s3 bucket is used. I had to switch from Conn Type: s3 to Conn Type: aws.

smentek avatar Oct 16 '19 11:10 smentek

Hi! I have the same issue as @chiju described. I'm running an airflow app with celery executor. I've tried playing around with the resource requests, changed the worker from deployment to statefulset but nothing worked. Do you have anything in mind that could solve this issue? Thanks

eagerstudent-sil avatar Apr 21 '20 08:04 eagerstudent-sil