question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Kubernetes Executor Config Volumes Break Airflow UI

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
dimbermancommented, Aug 7, 2020
0reactions
ajboscocommented, Dec 2, 2020

We’re hitting this same error. As @appunni-dishq pointed out above, it only happens in the graph UI when the DAG is enabled and has at least one DAG run.

Any suggestions on a workaround, @dimberman ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Kubernetes Executor — Airflow Documentation - Apache Airflow
This command generates the pods as they will be launched in Kubernetes and dumps them into yaml files for you to inspect.
Read more >
[GitHub] [airflow] dimberman commented on issue #9860
[GitHub] [airflow] dimberman commented on issue #9860: Kubernetes Executor Config Volumes Break Airflow UI · 2020-09-22 Thread GitBox.
Read more >
3 Ways to Run Airflow on Kubernetes - Fullstaq
Get started running Airflow on Kubernetes, containerizing your workloads, and using most out of both platforms, in 3 different ways.
Read more >
What's New In Airflow 2.0 and Kubernetes - YouTube
... what's new and improved in the world of Airflow 2.0 and Kubernetes. ... will talk about the newly designed KubernetesExecutor in Airflow...
Read more >
Airflow on Kubernetes: Containerizing your workflows - YouTube
In order to do this we used the following technologies: Helm to easily deploy Airflow on to Kubernetes; Airflow's Kubernetes Executor to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found