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/08/15 03:32:53 UTC

[airflow] 18/47: Respect DAG Serialization setting when running sync_perm (#10321)

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 fd0756cc59342ff742a0cf40e1c25d827491e77f
Author: Kaxil Naik <ka...@gmail.com>
AuthorDate: Thu Aug 13 20:38:49 2020 +0100

    Respect DAG Serialization setting when running sync_perm (#10321)
    
    We run this on Webserver Startup and when DAG Serialization is enabled we expect that no files are required but because of this bug the files were still looked for.
    
    (cherry picked from commit 2d4e44c04e78adf887cf7ebe3decfca64e7c9158)
---
 airflow/bin/cli.py | 2 +-
 tests/test_core.py | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/airflow/bin/cli.py b/airflow/bin/cli.py
index 51cf49d..c621a3a 100644
--- a/airflow/bin/cli.py
+++ b/airflow/bin/cli.py
@@ -1740,7 +1740,7 @@ def sync_perm(args): # noqa
         print('Updating permission, view-menu for all existing roles')
         appbuilder.sm.sync_roles()
         print('Updating permission on all DAG views')
-        dags = DagBag().dags.values()
+        dags = DagBag(store_serialized_dags=settings.STORE_SERIALIZED_DAGS).dags.values()
         for dag in dags:
             appbuilder.sm.sync_perm_for_dag(
                 dag.dag_id,
diff --git a/tests/test_core.py b/tests/test_core.py
index 5530f2a..3d8e688 100644
--- a/tests/test_core.py
+++ b/tests/test_core.py
@@ -1098,6 +1098,7 @@ class CliTests(unittest.TestCase):
             self.assertIn('user{}'.format(i), stdout)
 
     @mock.patch("airflow.settings.RBAC", True)
+    @mock.patch("airflow.settings.STORE_SERIALIZED_DAGS", True)
     @mock.patch("airflow.bin.cli.DagBag")
     def test_cli_sync_perm(self, dagbag_mock):
         self.expect_dagbag_contains([
@@ -1115,9 +1116,8 @@ class CliTests(unittest.TestCase):
         cli.sync_perm(args)
 
         self.appbuilder.sm.sync_roles.assert_called_once()
-
-        self.assertEqual(2,
-                         len(self.appbuilder.sm.sync_perm_for_dag.mock_calls))
+        dagbag_mock.assert_called_once_with(store_serialized_dags=True)
+        self.assertEqual(2, len(self.appbuilder.sm.sync_perm_for_dag.mock_calls))
         self.appbuilder.sm.sync_perm_for_dag.assert_any_call(
             'has_access_control',
             {'Public': {'can_dag_read'}}