Conversation
- Add DOMAIN_FAIR_SHARE to RBACElementType enum in types.py - Add DOMAIN_FAIR_SHARE to RESOURCE_GROUP scope combinations - Update FairShareDBSource.create_domain_fair_share() to use RBACEntityCreator - Update FairShareRepository.create_domain_fair_share() signature Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Changes: - Added RBACElementType.DOMAIN_FAIR_SHARE to types.py - Added to scope_entity_combinations.py under RESOURCE_GROUP - Updated EntityType.DOMAIN_FAIR_SHARE value from "domain:fair_share" to "domain_fair_share" - Updated FairShareDBSource and FairShareRepository to use RBACEntityCreator - Updated tests to use RBACEntityCreator and include AssociationScopesEntitiesRow table Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Applies the RBAC “Creator” pattern to DomainFairShare so that creating a domain fair share also participates in RBAC entity creation/association under a RESOURCE_GROUP scope.
Changes:
- Added
RBACElementType.DOMAIN_FAIR_SHAREand registered it underRESOURCE_GROUPscope/entity combinations. - Switched
DomainFairSharecreation path fromCreator/execute_creatortoRBACEntityCreator/execute_rbac_entity_creator. - Updated unit tests and DB setup to include the RBAC association table mapping.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/manager/repositories/fair_share/test_fair_share_repository.py | Updates tests to create DomainFairShare via RBACEntityCreator and registers RBAC association table for DB setup/cleanup. |
| src/ai/backend/manager/repositories/fair_share/repository.py | Changes repository API to accept RBACEntityCreator for domain fair share creation. |
| src/ai/backend/manager/repositories/fair_share/db_source/db_source.py | Uses execute_rbac_entity_creator when creating domain fair share records. |
| src/ai/backend/common/data/permission/types.py | Adds RBACElementType.DOMAIN_FAIR_SHARE and changes the EntityType.DOMAIN_FAIR_SHARE string value. |
| src/ai/backend/common/data/permission/scope_entity_combinations.py | Allows DOMAIN_FAIR_SHARE as a child entity under RESOURCE_GROUP scope. |
| changes/10025.feature.md | Adds changelog entry for the RBAC Creator pattern application. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| creator = RBACEntityCreator( | ||
| spec=DomainFairShareCreatorSpec( | ||
| resource_group=test_scaling_group, | ||
| domain_name=test_domain_name, | ||
| weight=Decimal("2.0"), | ||
| ) | ||
| ), | ||
| element_type=RBACElementType.DOMAIN_FAIR_SHARE, | ||
| scope_ref=RBACElementRef(RBACElementType.RESOURCE_GROUP, test_scaling_group), | ||
| ) | ||
|
|
||
| result = await fair_share_repository.create_domain_fair_share(creator) |
There was a problem hiding this comment.
These tests now use RBACEntityCreator, but they don’t assert the RBAC side-effect that motivates the change (i.e., that an association row is created in the RBAC association table for element_type=DOMAIN_FAIR_SHARE under the RESOURCE_GROUP scope). Adding an assertion that AssociationScopesEntitiesRow (or the equivalent RBAC association model) contains the expected scope/entity link would prevent regressions where execute_rbac_entity_creator() inserts only the fair-share row but fails to write the RBAC association.
…Creator Add DOMAIN_FAIR_SHARE to RBACElementTypeGQL enum to stay in sync with RBACElementType. Update test_scope_entity_combinations expected set and migrate test Creator calls to RBACEntityCreator for domain fair share. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: octodog <mu001@lablup.com>
Summary
RBACElementType.DOMAIN_FAIR_SHAREto RBAC type systemDOMAIN_FAIR_SHAREunderRESOURCE_GROUPin scope-entity combinationsFairShareDBSourceandFairShareRepositoryto useRBACEntityCreatorpatternThis applies the RBAC Creator pattern to DomainFairShare (auto sub-entity of ResourceGroup), following the same pattern as ProjectFairShare (BA-5076) and UserFairShare (BA-5077).
Test plan
pants fmt fix lint- all quality checks passedpants test- all fair_share repository tests passed (17 tests)Resolves BA-5075