Closed SulimanLab closed 3 years ago
Thanks for opening your first issue here! Be sure to follow the issue template!
anybody ??
I'm having this issue too. After upgrading to 2.0.0, while running with KubernetesExecutor
in an Azure k8s cluster, the worker pods have been failing with the same error message
Traceback (most recent call last):
File "/home/airflow/.local/bin/airflow", line 8, in <module>
sys.exit(main())
File "/home/airflow/.local/lib/python3.6/site-packages/airflow/__main__.py", line 40, in main
args.func(args)
File "/home/airflow/.local/lib/python3.6/site-packages/airflow/cli/cli_parser.py", line 48, in command
return func(*args, **kwargs)
File "/home/airflow/.local/lib/python3.6/site-packages/airflow/utils/cli.py", line 89, in wrapper
return f(*args, **kwargs)
File "/home/airflow/.local/lib/python3.6/site-packages/airflow/cli/commands/task_command.py", line 216, in task_run
dag = get_dag(args.subdir, args.dag_id)
File "/home/airflow/.local/lib/python3.6/site-packages/airflow/utils/cli.py", line 189, in get_dag
'parse.'.format(dag_id)
airflow.exceptions.AirflowException: dag_id could not be found: test. Either the dag did not exist or it failed to parse.
I access my DAGs via an Azure file store mounted as a volume using a pvc, and have found that the worker pods are not being created with the same mounted volume. It seems that the previously available airflow.cfg
values
[kubernetes]
dags_volume_claim =
dags_volume_subpath =
no longer exist in version 2.0.0, and the worker pods therefore cannot be created with the the proper volume mounts, leading to the above error.
Any way around this?
It turns out that as of 2.0.0, users are required to provide a pod_template_file
https://airflow.apache.org/docs/apache-airflow/stable/executor/kubernetes.html. This template replaces the functionality lost by the removal of the config values I mentioned above. I haven't tested that this solves my issue yet, but I suppose it should, as I can manually add the proper volume mounts to the template
@SulimanLab did you find a workaround?
In your init container, you have volumeMounts:
In your main container:
In airflow.cfg dags_folder = /opt/airflow/dags/repo/
So you airflow scheduler is expecting the dags to be placed under /opt/airflow/dags/repo/, however is that how you populate it in your init container? E.g do you have the "repo" directory ?
In your init container, you have volumeMounts:
- mountPath: /git name: dags
In your main container:
- mountPath: /opt/airflow/dags name: dags
In airflow.cfg dags_folder = /opt/airflow/dags/repo/
So you airflow scheduler is expecting the dags to be placed under /opt/airflow/dags/repo/, however is that how you populate it in your init container? E.g do you have the "repo" directory ?
yeah I have a repo contains all the dags files,
when task pod is instantiated it tries to git aync files , the issue is that it's not able to get the the secrets from volumes for gitsync.
this is what i think
@SulimanLab did you find a workaround?
no , still trying.
i changed the executor to celery executor
In your init container, you have volumeMounts:
- mountPath: /git name: dags
In your main container:
- mountPath: /opt/airflow/dags name: dags
In airflow.cfg dags_folder = /opt/airflow/dags/repo/ So you airflow scheduler is expecting the dags to be placed under /opt/airflow/dags/repo/, however is that how you populate it in your init container? E.g do you have the "repo" directory ?
yeah I have a repo contains all the dags files,
when task pod is instantiated it tries to git aync files , the issue is it's not able to get the the git details from the volumes.
this is what i think
What I meant is your scheduler is expecting /opt/airflow/dags/repo/bash.py, but it could be that your bash.py is in a different path such as
/opt/airflow/dags/bash.py
/opt/airflow/dags/repo/
make sure your file is located at the right place, it is very easy to inspect
@SulimanLab I got it to work with by replacing
- mountPath: {{ include "airflow_dags_mount_path" . }}
with
- mountPath: {{ include "airflow_dags" . }}
in https://github.com/apache/airflow/blob/master/chart/files/pod-template-file.kubernetes-helm-yaml#L65 I'm not sure if it's the right way of fixing it though
@SulimanLab I got it to work with by replacing
- mountPath: {{ include "airflow_dags_mount_path" . }}
with
- mountPath: {{ include "airflow_dags" . }}
in https://github.com/apache/airflow/blob/master/chart/files/pod-template-file.kubernetes-helm-yaml#L65 I'm not sure if it's the right way of fixing it though
wow, I will test that.
This commit is promising actually
https://github.com/apache/airflow/commit/8af5a33950cfe59a38931a8a605394ef0cbc3c08
@SulimanLab I'm testing with that commit and it hasn't worked.
This commit is promising actually
@SulimanLab it's a fix but it doesn't solve our issue
changing this line to 444 fixed the issue https://github.com/apache/airflow/blob/9592be88e57cc7f59b9eac978292abd4d7692c0b/chart/templates/_helpers.yaml#L114
changing this line to 444 fixed the issue
Really? I am using user and pass and webserver works but pods aren't. Anybody with a idea? I tried @varunvora solution but sscheduler doesn't work.
changing this line to 444 fixed the issue https://github.com/apache/airflow/blob/9592be88e57cc7f59b9eac978292abd4d7692c0b/chart/templates/_helpers.yaml#L114
Really? I am using user and pass and webserver works but pods aren't. Anybody with a idea? I tried @varunvora solution but sscheduler doesn't work.
I have the same problem. I've been testing all the comments here as well with no results.
changing this line to 444 fixed the issue https://github.com/apache/airflow/blob/9592be88e57cc7f59b9eac978292abd4d7692c0b/chart/templates/_helpers.yaml#L114
Really? I am using user and pass and webserver works but pods aren't. Anybody with a idea? I tried @varunvora solution but sscheduler doesn't work.
I have the same problem. I've been testing all the comments here as well with no results.
At last, it works. Resumen: Edit pod-template In line 64, I modified the lines to change mountPath: `{{- if or .Values.dags.gitSync.enabled .Values.dags.persistence.enabled }}
changing this line to 444 fixed the issue https://github.com/apache/airflow/blob/9592be88e57cc7f59b9eac978292abd4d7692c0b/chart/templates/_helpers.yaml#L114
Really? I am using user and pass and webserver works but pods aren't. Anybody with a idea? I tried @varunvora solution but sscheduler doesn't work.
Try ssh login, and change as mentioned above, pretty sure it will work.
changing this line to 444 fixed the issue https://github.com/apache/airflow/blob/9592be88e57cc7f59b9eac978292abd4d7692c0b/chart/templates/_helpers.yaml#L114
Really? I am using user and pass and webserver works but pods aren't. Anybody with a idea? I tried @varunvora solution but sscheduler doesn't work.
I have the same problem. I've been testing all the comments here as well with no results.
At last, it works. Resumen: Edit pod-template In line 64, I modified the lines to change mountPath:
{{- if or .Values.dags.gitSync.enabled .Values.dags.persistence.enabled }} - mountPath: {{ include "airflow_dags" . }} name: dags readOnly: true {{- if .Values.dags.gitSync.enabled }} subPath: {{.Values.dags.gitSync.dest }}/{{ .Values.dags.gitSync.subPath }} {{- end }} {{- end }}
@ismaello This does the same as what I suggested right?
If you are using gitSync and KubernetesExecutor, DAGs persistence in the worker pod is meaningless. I hope #13826 is merged.
I had to create a pod template file :
dev-airflow-worker.yaml
apiVersion: v1
kind: Pod
metadata:
name: dummy-name
spec:
containers:
- env:
- name: AIRFLOW__CORE__DAGS_FOLDER
value: /opt/bitnami/airflow/dags/git-airflow-dags/repo/
- name: AIRFLOW__CORE__EXECUTOR
value: LocalExecutor
- name: AIRFLOW__CORE__SQL_ALCHEMY_CONN
value: xxxxxxxxxxxxxx
- name: AIRFLOW__CORE__FERNET_KEY
value: xxxxxxxxxxxxxxx
image: bitnami/airflow-worker:2.0.0-debian-10-r5
name: base
volumeMounts:
- mountPath: /opt/bitnami/airflow/dags/git-airflow-dags
name: airflow-dags
readOnly: true
subPath: ./repo/
initContainers:
- env:
- name: GIT_SYNC_REPO
value: https://gitlab..........................
- name: GIT_SYNC_BRANCH
value: dev
- name: GIT_SYNC_ROOT
value: /dags-airflow-dags
- name: GIT_SYNC_DEST
value: repo
- name: GIT_SYNC_DEPTH
value: "1"
- name: GIT_SYNC_ONE_TIME
value: "true"
- name: GIT_SYNC_REV
- name: GIT_SYNC_USERNAME
value: aleopold
- name: GIT_SYNC_PASSWORD
value: xxxxxxxxxxxxxxxxxxxxxxxxxxx
- name: GIT_KNOWN_HOSTS
value: "false"
image: k8s.gcr.io/git-sync:v3.1.1
imagePullPolicy: IfNotPresent
name: git-sync-clone
securityContext:
runAsUser: 65533
volumeMounts:
- mountPath: /dags-airflow-dags
name: airflow-dags
securityContext:
fsGroup: 50000
runAsUser: 50000
serviceAccount: airflow-deployement
serviceAccountName: airflow-deployement
volumes:
- name: airflow-dags
And in the helm-chart's values.yaml
https://artifacthub.io/packages/helm/bitnami/airflow
airflow:
extraEnvVars:
- name: AIRFLOW_EXECUTOR
value: "KubernetesExecutor"
- name: AIRFLOW__KUBERNETES__POD_TEMPLATE_FILE
value: "/opt/bitnami/airflow/dags/git-airflow-dags/dev-airflow-worker.yaml"
- name: AIRFLOW__KUBERNETES__FS_GROUP
value: "50000"
hope it helps
I had the same problem.
In my case, given gitSync.subPath as the empty string.
I fixed that problem after give the correct value.
dags:
gitSync:
subPath: path/to/dags
hope it helps
Apache Airflow version: 2.0.0
Kubernetes version (if you are using kubernetes) (use
kubectl version
): v1.19.4What happened: I get this error when try to execute tasks using kubernetes
What you expected to happen: get executed and terminate
How to reproduce it: deploy airflow helm chart using this values.yaml:
and this is the dag with its tasks
This is airflow.cfg file
This is the pod yaml file for the new tasks
-----------------------Important----------------------------
Debugging
for debugging purpose I have changed the pod args rather than running the task, I ran it with
and tried to look for the Dags , and found None. It seems like gitSync is not working with the pods triggered by kubernetesExecutor.
Any help please ???