Skip to content

Conversation

@Misha-Shvets
Copy link
Collaborator

@Misha-Shvets Misha-Shvets commented Jan 13, 2026

Переименование раздела services в System по аналогии с АД

Задача: 1084

Copy link
Collaborator

@milov-dmitriy milov-dmitriy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

главное проверь это локально любым из способов, главное чтобы переименование сработало корректно и даунгрейд тоже сработал корректно

"""Upgrade: Rename 'services' container to 'System'."""

async def _rename_services_to_system(connection: AsyncConnection) -> None:
session = AsyncSession(bind=connection)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

из контейнера берем теперь сесиию

Comment on lines +33 to +36
base_directories = await get_base_directories(session)
if not base_directories:
await session.commit()
return
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

это можно наружу, зачем это внутри try

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

или может вообще уберем try? у нас это не очень распространенная практика

Comment on lines +43 to +50
system_exists = await session.scalar(
select(exists(Directory)).where(
and_(
qa(Directory.name) == "System",
qa(Directory.parent_id) == services_dir.parent_id,
),
),
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

select(exists().where())
а у тебя так:
select(exists()).where()

проверь работоспособность этого решения в реалтайме плз

Copy link
Collaborator

@milov-dmitriy milov-dmitriy Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

можно создать любые директории-контейнеры и прочее руками, а затем сделать make downgrade чтоб откатить и накатить эту миграцию или можно просто сделать чекаут с dev на твою ветку

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. тут точно нельзя никак по другому запрос написать?

можно в запрос встроить parent_id.in_(service_dir_ids) (псевдокод)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. предлагаю сделать "команда с отдельной строки" как у нас везде принято:
select
where

Comment on lines +93 to +97
result = await session.execute(
select(Attribute).where(
Attribute.value.ilike(f"%{old_value}%"), # type: ignore
),
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

предлагаю сделать "команда с отдельной строки" как у нас везде принято:

select
where

Comment on lines +76 to +78
children = await session.scalars(
select(Directory).where(qa(Directory.parent_id) == parent_id),
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

предлагаю сделать "команда с отдельной строки" как у нас везде принято:

select
where

select(Directory).where(qa(Directory.parent_id) == parent_id),
)

for child in children:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

child -> child_dir

Comment on lines +109 to +111
def downgrade(container: AsyncContainer) -> None: # noqa: ARG001
"""Downgrade: Rename 'System' container back to 'services'."""

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

проверь downgrade на аналогичные комментарии что и upgrade

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. неминг
  2. форматирование запросов
  3. необходимость try-блока

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. сессия из контейнера

Comment on lines 293 to +296
base_dn, domain = await self._get_base_dn()
krbadmin = f"cn=krbadmin,cn=users,{base_dn}"
krbgroup = f"cn=krbadmin,cn=groups,{base_dn}"
services_container = f"ou=services,{base_dn}"
services_container = get_services_container_dn(base_dn)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] можем сделать для krbadmin, krbgroup, ... аналогичный метод что и для services_container

м?

Comment on lines +136 to +138
def get_services_container_dn(base_dn: str) -> str:
"""Get System container DN for services."""
return f"ou=System,{base_dn}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а это точно к керберосу относится а не к лдапу?

- ./certs:/certs
- ./app:/app
- ldap_keytab:/LDAP_keytab/
- kdc:/etc/krb5kdc/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

а это нужная для этого ПР правка? не могу разобраться



def upgrade(container: AsyncContainer) -> None: # noqa: ARG001
"""Upgrade: Rename 'services' container to 'System'."""
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] название System именно в upper кейсе?
просто у нас везде lower, и это как будто выбивается из общей практики, я бы уточнил у автора задачи

Copy link
Collaborator

@milov-dmitriy milov-dmitriy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

и еще надо будет подлить к тебе мою задачу 796, т.к. я в ней добавляю понятие системная директория или нет, если системная - значит ее нельзя менять

upd. но это уже после того как ее апрувнут, но я бы предлагал сначала мою апрувать потом твою

depends_on: None | list[str] = None


def upgrade(container: AsyncContainer) -> None: # noqa: ARG001
Copy link
Collaborator

@milov-dmitriy milov-dmitriy Jan 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

еще что не могу понять, а что если в лдап дереве нет директории с именем service ? мы же тогда просто выйдем из миграции, и кажется , что это не совсем правильно, наверное стоит создавать директорию System в таком случае

не знаю, стоит ли мне лезть в бизнеслогику, но не знаю в общем...

await session.flush()
await _update_descendants(session, services_dir.id)

await _update_attributes(session, "ou=services", "ou=System")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

предлагаю строго привязывать к id той директории которую мы обновили, т.е. передавать в _update_attributes еще и directory_id, чтобы не сделать "лишних" изменений у тех директорий, которые в отбор не попали, но атрибуты которых попали под фильтр атрибутов. думаю, это повысит надежность миграции

@milov-dmitriy milov-dmitriy changed the title Services to system 1084 Add: Services to system Jan 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants