Skip to content

Commit

Permalink
Allow migration only on read only mode
Browse files Browse the repository at this point in the history
  • Loading branch information
lpichler committed Nov 7, 2024
1 parent eeaf66d commit bc7f434
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions rbac/migration_tool/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import logging
from typing import Iterable

from django.conf import settings
from django.db import transaction
from kessel.relations.v1beta1 import common_pb2
from management.group.relation_api_dual_write_group_handler import RelationApiDualWriteGroupHandler
Expand Down Expand Up @@ -154,6 +155,10 @@ def migrate_data_for_tenant(tenant: Tenant, exclude_apps: list, replicator: Rela

def migrate_data(exclude_apps: list = [], orgs: list = [], write_relationships: str = "False"):
"""Migrate all data for all tenants."""
if not settings.READ_ONLY_API_MODE:
logger.info("Read-only API mode is required. READ_ONLY_API_MODE must be set to true.")
return

count = 0
tenants = Tenant.objects.exclude(tenant_name="public")
replicator = _get_replicator(write_relationships)
Expand Down
2 changes: 1 addition & 1 deletion tests/migration_tool/tests_migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def setUp(self):
tenant_default_policy.roles.add(self.system_role_2)
self.custom_default_group = group

@override_settings(REPLICATION_TO_RELATION_ENABLED=True, PRINCIPAL_USER_DOMAIN="redhat")
@override_settings(REPLICATION_TO_RELATION_ENABLED=True, PRINCIPAL_USER_DOMAIN="redhat", READ_ONLY_API_MODE=True)
@patch("management.relation_replicator.logging_replicator.logger")
def test_migration_of_data(self, logger_mock):
"""Test that we get the correct access for a principal."""
Expand Down

0 comments on commit bc7f434

Please sign in to comment.