Skip to content

Conversation

@snjypl
Copy link
Contributor

@snjypl snjypl commented Dec 29, 2022

*** Fetching from: http://airflow-scheduler-0.airflow-scheduler.airflow.svc.cluster.local:8793/log/dag_id=example_bash_operator/run_id=manual__2022-12-29T08:33:49.310825+00:00/task_id=runme_1/attempt=1.log
*** Failed to fetch log file from worker. [Errno 111] Connection refused

For LocalKubernetesExecutor we are not able to fetch the logs for local tasks.

the scheduler is not starting the serve_logs process.

executor_class, _ = ExecutorLoader.import_default_executor_cls()
if executor_class.is_local:
if skip_serve_logs is False:
sub_proc = Process(target=serve_logs)
sub_proc.start()

we need to set is_local to true for LocalKubernetesExecutor

also in the helm chart, when the executor is LocalKubernetesExecutor we need to create the scheduler service so that the tasks logs can be fetched.


^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in newsfragments.

@boring-cyborg boring-cyborg bot added area:CLI area:helm-chart Airflow Helm Chart area:Scheduler including HA (high availability) scheduler labels Dec 29, 2022
@dstandish
Copy link
Contributor

dstandish commented Dec 29, 2022

How about we create flag serve_logs and add this to base executor and use this instead of is_local in all executors to control log serving?

CC @potiuk @o-nikolas

## Airflow Scheduler Service
#################################
{{- if eq .Values.executor "LocalExecutor" }}
{{- if or (eq .Values.executor "LocalExecutor") (eq .Values.executor "LocalKubernetesExecutor")}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we want to make our Chart fully compatible with AIP-51 and allow "any" executors we should also implement some way to override Helm Chart behaviour for custom executors. But we can do it later. CC: @o-nikolas

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah.. I see @dstandish already had some comments on that one too :) Yeah - serve_logs should be fine and it should have default value depending on the "built-in" executors - so that we do not have to configure it manually for built-in executors.

@snjypl
Copy link
Contributor Author

snjypl commented Dec 29, 2022

@potiuk i noticed that airflow-worker service account is not getting created for LocalKubernetesExecutor.

shall i create a new PR with all the helm chart related changes? or it can be part of this PR?

kubernetes.client.exceptions.ApiException: (403)
Reason: Forbidden
HTTP response headers: HTTPHeaderDict({'Audit-Id': '6000d700-1b7b-413b-a49f-3eba7114bbf7', 'Cache-Control': 'no-cache, private', 'Content-Type': 'application/json', 'X-Kubernetes-Pf-Flowschema-Uid': 'e6bfeec0-ef68-4420-88d8-b7024eed9fea', 'X-Kubernetes-Pf-Prioritylevel-Uid': '0e598fd5-a817-46f7-be85-6ac94aeb7872', 'Date': 'Thu, 29 Dec 2022 18:57:06 GMT', 'Content-Length': '400'})
HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"pods \"example-local-kubernetes-executor-task-with-kubernetes-c5u03pq1\" is forbidden: error looking up service account airflow/airflow-worker: serviceaccount \"airflow-worker\" not found","reason":"Forbidden","details":{"name":"example-local-kubernetes-executor-task-with-kubernetes-c5u03pq1","kind":"pods"},"code":403}
[2022-12-29T18:57:06.871+0000] {kubernetes_executor.py:686} WARNING - ApiException when attempting to run task, re-queueing. Reason: 'Forbidden'. Message: pods "example-local-kubernetes-executor-task-with-kubernetes-c5u03pq1" is forbidden: error looking up service account airflow/airflow-worker: serviceaccount "airflow-worker" not found

@o-nikolas
Copy link
Contributor

Hey folks!

I definitely agree with splitting out is_local into more fine grained compatibility flags/properties (see here for more context). Also expect an AIP soon which will deliver native support for hybrid executors (of any combination) rather than these handbuilt classes which combine two explicit executors 🚀

@snjypl snjypl force-pushed the bugfix/LocalK8sExecutor-scheduler-log-serving-logs branch from 503faf7 to 814ef0e Compare January 6, 2023 22:13
@snjypl
Copy link
Contributor Author

snjypl commented Jan 6, 2023

@dstandish i have added serve_logs flag

@snjypl snjypl force-pushed the bugfix/LocalK8sExecutor-scheduler-log-serving-logs branch from 814ef0e to 0524994 Compare January 9, 2023 12:18
@snjypl
Copy link
Contributor Author

snjypl commented Jan 9, 2023

@potiuk i noticed that airflow-worker service account is not getting created for LocalKubernetesExecutor.

shall i create a new PR with all the helm chart related changes? or it can be part of this PR?

kubernetes.client.exceptions.ApiException: (403)
Reason: Forbidden
HTTP response headers: HTTPHeaderDict({'Audit-Id': '6000d700-1b7b-413b-a49f-3eba7114bbf7', 'Cache-Control': 'no-cache, private', 'Content-Type': 'application/json', 'X-Kubernetes-Pf-Flowschema-Uid': 'e6bfeec0-ef68-4420-88d8-b7024eed9fea', 'X-Kubernetes-Pf-Prioritylevel-Uid': '0e598fd5-a817-46f7-be85-6ac94aeb7872', 'Date': 'Thu, 29 Dec 2022 18:57:06 GMT', 'Content-Length': '400'})
HTTP response body: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"pods \"example-local-kubernetes-executor-task-with-kubernetes-c5u03pq1\" is forbidden: error looking up service account airflow/airflow-worker: serviceaccount \"airflow-worker\" not found","reason":"Forbidden","details":{"name":"example-local-kubernetes-executor-task-with-kubernetes-c5u03pq1","kind":"pods"},"code":403}
[2022-12-29T18:57:06.871+0000] {kubernetes_executor.py:686} WARNING - ApiException when attempting to run task, re-queueing. Reason: 'Forbidden'. Message: pods "example-local-kubernetes-executor-task-with-kubernetes-c5u03pq1" is forbidden: error looking up service account airflow/airflow-worker: serviceaccount "airflow-worker" not found

@Chen-Oliver has opened a PR for this particular issue: #28813

@snjypl snjypl force-pushed the bugfix/LocalK8sExecutor-scheduler-log-serving-logs branch from 0524994 to b069eb7 Compare January 10, 2023 10:02
@o-nikolas
Copy link
Contributor

Anyone have some time to give this a second review/approval? Would be nice to get this merged for @snjypl
Maybe @potiuk, @dstandish or @pierrejeambrun?

Copy link
Member

@pierrejeambrun pierrejeambrun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pierrejeambrun
Copy link
Member

pierrejeambrun commented Jan 16, 2023

Could use a rebase before merging, it's 20+ commits behind main

@snjypl
Copy link
Contributor Author

snjypl commented Jan 16, 2023

Could use a rebase before merging, it's 20+ commits behind master

Done.

@pierrejeambrun pierrejeambrun merged commit 65010fd into apache:main Jan 16, 2023
@snjypl snjypl deleted the bugfix/LocalK8sExecutor-scheduler-log-serving-logs branch January 17, 2023 08:25
@pierrejeambrun pierrejeambrun added this to the Airflow 2.5.2 milestone Feb 27, 2023
@pierrejeambrun pierrejeambrun added type:bug-fix Changelog: Bug Fixes changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) AIP-51 AIP-51: Remove executor coupling from Core and removed type:bug-fix Changelog: Bug Fixes labels Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AIP-51 AIP-51: Remove executor coupling from Core area:CLI area:helm-chart Airflow Helm Chart area:Scheduler including HA (high availability) scheduler changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants