airflow: Kubernetes Executor Config Volumes Break Airflow UI

Apache Airflow version: 1.10.11

Kubernetes version (if you are using kubernetes) (use kubectl version): 1.16.9

Environment:

  • Cloud provider or hardware configuration: AWS
  • OS (e.g. from /etc/os-release): Ubuntu
  • Kernel (e.g. uname -a): 5.3.0-1019-aws #21~18.04.1-Ubuntu SMP x86_64 GNU/Linux
  • Install tools: Docker image with Airflow pip installed via pipenv

What happened:

After adding a specification for Volume and VolumeMount objects to the executor_config for KubernetesExecutor, the Airflow UI explodes with the following message when I try to clear the task or do any other action on it:

TypeError: Object of type VolumeMount is not JSON serializable

Once this error is thrown after clearing a task with the volume-containing executor_config, that DAG no longer loads at all in the Airflow UI

What you expected to happen:

The KubernetesExecutor dynamically adds my specific volumes to the Pod spec

How to reproduce it: In an Airflow environment configured to use the KubernetesExecutor, pass a spec of the following form to the executor_config:

from airflow.kubernetes.volume_mount import VolumeMount
from airflow.kubernetes.volume import Volume

my_volume = Volume(
    name='my-pvc',
    configs={
        'persistentVolumeClaim': {'claimName': 'my-pvc'}
    }
)
my_volume_mount = VolumeMount(
    name='my-pvc', mount_path='/example/mount/path',
    sub_path=None, read_only=False
)

executor_config = {
    'KubernetesExecutor': {'volumes': [my_volume], 'volume_mounts': [my_volume_mount]}
}

# I didn't bother defining an example DAG, this should cause an issue with any operator
my_task = BashOperator(task_id='example-task', executor_config=executor_config, dag=dag)

Once such a task is defined, click the Clear button from the UI and it will throw the TypeError above

Anything else we need to know:

Obviously the volume mounts specified via airflow.cfg work, but we’d like to be able to dynamically add volumes to tasks that need them without having all of our jobs mount volumes unnecessarily

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19 (7 by maintainers)

Most upvoted comments