Skip to content

Conversation

@MinJuTur
Copy link
Contributor

@MinJuTur MinJuTur commented Feb 2, 2026

Summary

  • Introduce the BatchPurger pattern in DomainRepository.purge_domain() for domain-related deletions
  • Add DomainKernelBatchPurgerSpec and DomainBatchPurgerSpec for batch deletion of kernels and domains
  • Migrate purge_domain() and related helper methods from SAConnection (Core) to SASession (ORM)
  • Add integration tests for domain purger specs

Related Issue

Test plan

  • pants lint src/ai/backend/manager/repositories/domain::
  • pants check src/ai/backend/manager/repositories/domain::
  • pants test tests/unit/manager/repositories/domain::

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings February 2, 2026 09:37
@github-actions github-actions bot added size:L 100~500 LoC comp:manager Related to Manager component labels Feb 2, 2026
Comment on lines 108 to 114
async def soft_delete_domain(self, domain_name: str) -> None:
"""
Soft deletes a domain by setting is_active to False.
Validates domain deletion permissions.
"""
async with self._db.begin() as conn:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

soft_delete_domain() still uses SAConnection. Only purge_domain() and its helper methods were migrated to SASession in this PR.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors domain deletion to use the BatchPurger pattern, migrating from Core SQLAlchemy operations (AsyncConnection) to ORM operations (AsyncSession). This brings consistency with other repositories in the codebase that have already adopted this pattern (e.g., GroupRepository, UserRepository).

Changes:

  • Introduced DomainKernelBatchPurgerSpec and DomainBatchPurgerSpec for structured batch deletion operations
  • Migrated purge_domain() and helper methods from AsyncConnection to AsyncSession
  • Added integration tests for the new purger specifications

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/ai/backend/manager/repositories/domain/purgers.py New file defining batch purger specs for domain and kernel deletions, following the established pattern in the codebase
src/ai/backend/manager/repositories/domain/repository.py Updated purge_domain() to use BatchPurger pattern; migrated helper methods from Core (AsyncConnection) to ORM (AsyncSession); updated imports to use Row classes instead of table objects
tests/unit/manager/repositories/domain/test_domain_purgers.py New integration tests for domain purger specs with comprehensive fixture setup and assertions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

from ai.backend.manager.models.utils import ExtendedAsyncSAEngine


class TestDomainPurgersIntegration:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The initial plan included keypair_resource_policy, sample_keypair, and sample_scaling_group fixtures, but they turned out to be unnecessary for these purger spec tests. So I excluded them.

@MinJuTur MinJuTur requested a review from jopemachine February 3, 2026 02:11
@jopemachine jopemachine added this pull request to the merge queue Feb 3, 2026
@jopemachine jopemachine added this to the 26.2 milestone Feb 3, 2026
@jopemachine jopemachine removed this pull request from the merge queue due to a manual request Feb 3, 2026
@jopemachine jopemachine added this pull request to the merge queue Feb 3, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 3, 2026
MinJuTur and others added 6 commits February 3, 2026 04:52
Replace raw SQL deletion with BatchPurger pattern in
DomainRepository.purge_domain() for consistent and maintainable
domain data deletion.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Align with the group test convention where sample_domain returns
a plain string instead of DomainRow object.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
asyncio_mode = "auto" is configured in pyproject.toml, making
explicit @pytest.mark.asyncio decorators redundant.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…sionMap

Fix test fixtures to use ResourceSlot({}) and VFolderHostPermissionMap({})
instead of plain dict, as the model columns now require these types.

Also remove @pytest.mark.asyncio decorators (asyncio_mode=auto).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@MinJuTur MinJuTur force-pushed the refactor/BA-3764-add-purger-pattern-to-domain-repository branch from 046eb72 to 85fb1cc Compare February 3, 2026 04:59
@MinJuTur MinJuTur requested a review from jopemachine February 3, 2026 05:01
@jopemachine jopemachine added this pull request to the merge queue Feb 3, 2026
Merged via the queue into main with commit 27b80a9 Feb 3, 2026
30 checks passed
@jopemachine jopemachine deleted the refactor/BA-3764-add-purger-pattern-to-domain-repository branch February 3, 2026 05:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:manager Related to Manager component Intern-OKR size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants