Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respect DAG Serialization setting when running sync_perm #10321

Merged
merged 1 commit into from
Aug 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion airflow/cli/commands/sync_perm_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions tests/cli/commands/test_sync_perm_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def setUpClass(cls):

@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',
Expand All @@ -51,6 +52,7 @@ def test_cli_sync_perm(self, dagbag_mock, mock_cached_app):

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',
Expand Down