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 2020/06/22 19:18:39 UTC

[airflow] 02/02: Fix connection add/edit for spark (#8685)

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

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

commit 215fc24b12b9923ccf572da8d10e528caae46904
Author: Xiaodong DENG <xd...@hotmail.com>
AuthorDate: Sun May 3 20:17:21 2020 +0200

    Fix connection add/edit for spark (#8685)
    
    connection add/edit UI pages were not working correctly for Spark connections.
    
    The root-cause is that "spark" is not listed in models.Connection._types.
    So when www/forms.py tries to produce the UI,
    "spark" is not available and it always tried to "fall back" to the option list
    whose first entry is "Docker"
    
    In addition, we should hide irrelevant entries for
    spark connections ("schema", "login", and "password")
    
    (cherry picked from commit 0b598a2162e9d27160f0afe19e8908df735068af)
---
 airflow/models/connection.py                  | 1 +
 airflow/www/static/connection_form.js         | 4 ++++
 airflow/www_rbac/static/js/connection_form.js | 4 ++++
 3 files changed, 9 insertions(+)

diff --git a/airflow/models/connection.py b/airflow/models/connection.py
index a1c2253..0ab305f 100644
--- a/airflow/models/connection.py
+++ b/airflow/models/connection.py
@@ -108,6 +108,7 @@ class Connection(Base, LoggingMixin):
         ('gcpcloudsql', 'Google Cloud SQL'),
         ('grpc', 'GRPC Connection'),
         ('yandexcloud', 'Yandex Cloud'),
+        ('spark', 'Spark'),
     ]
 
     def __init__(
diff --git a/airflow/www/static/connection_form.js b/airflow/www/static/connection_form.js
index 0f668ae..2ffab82 100644
--- a/airflow/www/static/connection_form.js
+++ b/airflow/www/static/connection_form.js
@@ -74,6 +74,10 @@
             hidden_fields: ['host', 'schema', 'login', 'password', 'port', 'extra'],
             relabeling: {},
         },
+        spark: {
+            hidden_fields: ['schema', 'login', 'password'],
+            relabeling: {},
+        },
       }
       function connTypeChange(connectionType) {
         $("div.form-group").removeClass("hide");
diff --git a/airflow/www_rbac/static/js/connection_form.js b/airflow/www_rbac/static/js/connection_form.js
index 8e371fa..95f3ab1 100644
--- a/airflow/www_rbac/static/js/connection_form.js
+++ b/airflow/www_rbac/static/js/connection_form.js
@@ -61,6 +61,10 @@ $(document).ready(function () {
         'login': 'Username',
       }
     },
+    spark: {
+      hidden_fields: ['schema', 'login', 'password'],
+      relabeling: {},
+    },
   };
 
   function connTypeChange(connectionType) {