You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2020/08/13 19:40:00 UTC
[airflow] branch master updated: Respect DAG Serialization setting
when running sync_perm (#10321)
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/master by this push:
new 2d4e44c Respect DAG Serialization setting when running sync_perm (#10321)
2d4e44c is described below
commit 2d4e44c04e78adf887cf7ebe3decfca64e7c9158
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.
---
airflow/cli/commands/sync_perm_command.py | 3 ++-
tests/cli/commands/test_sync_perm_command.py | 2 ++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/airflow/cli/commands/sync_perm_command.py b/airflow/cli/commands/sync_perm_command.py
index cf490b3..8c9aad8 100644
--- a/airflow/cli/commands/sync_perm_command.py
+++ b/airflow/cli/commands/sync_perm_command.py
@@ -16,6 +16,7 @@
# specific language governing permissions and limitations
# under the License.
"""Sync permission command"""
+from airflow import settings
from airflow.models import DagBag
from airflow.utils import cli as cli_utils
from airflow.www.app import cached_app
@@ -28,7 +29,7 @@ def sync_perm(args):
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/cli/commands/test_sync_perm_command.py b/tests/cli/commands/test_sync_perm_command.py
index 88753c7..a555180 100644
--- a/tests/cli/commands/test_sync_perm_command.py
+++ b/tests/cli/commands/test_sync_perm_command.py
@@ -33,6 +33,7 @@ class TestCliSyncPerm(unittest.TestCase):
@mock.patch("airflow.cli.commands.sync_perm_command.cached_app")
@mock.patch("airflow.cli.commands.sync_perm_command.DagBag")
+ @mock.patch("airflow.settings.STORE_SERIALIZED_DAGS", True)
def test_cli_sync_perm(self, dagbag_mock, mock_cached_app):
self.expect_dagbag_contains([
DAG('has_access_control',
@@ -51,6 +52,7 @@ class TestCliSyncPerm(unittest.TestCase):
assert appbuilder.sm.sync_roles.call_count == 1
+ dagbag_mock.assert_called_once_with(store_serialized_dags=True)
self.assertEqual(2, len(appbuilder.sm.sync_perm_for_dag.mock_calls))
appbuilder.sm.sync_perm_for_dag.assert_any_call(
'has_access_control',