-
Notifications
You must be signed in to change notification settings - Fork 0
Add: Services to system #883
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
base: dev
Are you sure you want to change the base?
Conversation
…or services and system
…es for Kerberos configuration files
…es, enhance config update script, and simplify test case
38592fb to
88cc71a
Compare
milov-dmitriy
left a comment
There was a problem hiding this 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
из контейнера берем теперь сесиию
| base_directories = await get_base_directories(session) | ||
| if not base_directories: | ||
| await session.commit() | ||
| return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
это можно наружу, зачем это внутри try
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
или может вообще уберем try? у нас это не очень распространенная практика
| system_exists = await session.scalar( | ||
| select(exists(Directory)).where( | ||
| and_( | ||
| qa(Directory.name) == "System", | ||
| qa(Directory.parent_id) == services_dir.parent_id, | ||
| ), | ||
| ), | ||
| ) |
There was a problem hiding this comment.
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()
проверь работоспособность этого решения в реалтайме плз
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
можно создать любые директории-контейнеры и прочее руками, а затем сделать make downgrade чтоб откатить и накатить эту миграцию или можно просто сделать чекаут с dev на твою ветку
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- тут точно нельзя никак по другому запрос написать?
можно в запрос встроить parent_id.in_(service_dir_ids) (псевдокод)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- предлагаю сделать "команда с отдельной строки" как у нас везде принято:
select
where
| result = await session.execute( | ||
| select(Attribute).where( | ||
| Attribute.value.ilike(f"%{old_value}%"), # type: ignore | ||
| ), | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
предлагаю сделать "команда с отдельной строки" как у нас везде принято:
select
where
| children = await session.scalars( | ||
| select(Directory).where(qa(Directory.parent_id) == parent_id), | ||
| ) |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
child -> child_dir
| def downgrade(container: AsyncContainer) -> None: # noqa: ARG001 | ||
| """Downgrade: Rename 'System' container back to 'services'.""" | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
проверь downgrade на аналогичные комментарии что и upgrade
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- неминг
- форматирование запросов
- необходимость try-блока
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- сессия из контейнера
| 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) |
There was a problem hiding this comment.
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
м?
| def get_services_container_dn(base_dn: str) -> str: | ||
| """Get System container DN for services.""" | ||
| return f"ou=System,{base_dn}" |
There was a problem hiding this comment.
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/ |
There was a problem hiding this comment.
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'.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] название System именно в upper кейсе?
просто у нас везде lower, и это как будто выбивается из общей практики, я бы уточнил у автора задачи
There was a problem hiding this 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 |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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, чтобы не сделать "лишних" изменений у тех директорий, которые в отбор не попали, но атрибуты которых попали под фильтр атрибутов. думаю, это повысит надежность миграции
Переименование раздела
servicesвSystemпо аналогии с АДЗадача: 1084