You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2021/04/09 20:36:41 UTC

[airflow] 01/03: Bugfix: resources in `executor_config` breaks Graph View in UI (#15199)

This is an automated email from the ASF dual-hosted git repository.

kaxilnaik pushed a commit to branch v2-0-test
in repository https://gitbox.apache.org/repos/asf/airflow.git

commit 4bb8876ecb9547862e6134f83293f39dded7c9c2
Author: Kaxil Naik <ka...@gmail.com>
AuthorDate: Mon Apr 5 12:41:29 2021 +0100

    Bugfix: resources in `executor_config` breaks Graph View in UI (#15199)
    
    closes https://github.com/apache/airflow/issues/14327
    
    When using `KubernetesExecutor` and the task as follows:
    
    ```python
    PythonOperator(
        task_id=f"sync_{table_name}",
        python_callable=sync_table,
        provide_context=True,
        op_kwargs={"table_name": table_name},
        executor_config={"KubernetesExecutor": {"request_cpu": "1"}},
        retries=5,
        dag=dag,
    )
    ```
    
    it breaks the UI as settings resources in such a way is only there
    for backwards compatibility.
    
    This commits fixes it.
    
    (cherry picked from commit 7b577c35e241182f3f3473ca02da197f1b5f7437)
---
 airflow/utils/json.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/airflow/utils/json.py b/airflow/utils/json.py
index 45dda75..8e22408 100644
--- a/airflow/utils/json.py
+++ b/airflow/utils/json.py
@@ -66,7 +66,7 @@ class AirflowJsonEncoder(JSONEncoder):
             obj, (np.float_, np.float16, np.float32, np.float64, np.complex_, np.complex64, np.complex128)
         ):
             return float(obj)
-        elif k8s is not None and isinstance(obj, k8s.V1Pod):
+        elif k8s is not None and isinstance(obj, (k8s.V1Pod, k8s.V1ResourceRequirements)):
             from airflow.kubernetes.pod_generator import PodGenerator
 
             return PodGenerator.serialize_pod(obj)