lablup / lablup/backend.ai

[ScalingGroup] Migrate RBAC entity association to `scaling_group_id`

Open
#11,622 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
670
Forks
183
Avg merge
17h 7m
Merged PRs (30d)
358

Description

## Goal

Switch the current RBAC pattern (RBACEntityCreator / RBACEntityPurger / RBACElementRef and the association_scopes_entities table) to identify ScalingGroups by `id` instead of `name`. Migrate existing rows accordingly.

## Scope

- Alembic data migration: backfill `association_scopes_entities.entity_id` (and `scope_id` if used) from `scaling_groups.name` to `scaling_groups.id::text` where the corresponding type is `RESOURCE_GROUP`. Provide downgrade.
- Update every call site that constructs `RBACElementRef(RBACElementType.RESOURCE_GROUP, element_id=...)` so it passes `scaling_group.id` (or `ResourceGroupID`) instead of the name.
- Update `RBACEntityCreator` / `RBACEntityPurger` usage in ScalingGroup create / purge paths so the registered `entity_id` uses `scaling_group_id`. Add the missing RBAC entity registration on create / purge if it is not currently wired (see `repositories/scaling_group/db_source/db_source.py` :: `create_scaling_group` / `purge_scaling_group`).
- Update repositories / services that build `RBACElementRef` for ScalingGroup on role-grant / role-revoke / permission lookup paths.
- Tests: update RBAC entity-association tests to expect id-based `entity_id`.

## Explicitly out of scope (legacy RBAC, do NOT touch)

- `ScalingGroup(ExtraScope)` / `ScalingGroup` legacy scope class
- `scope_binder` and any \*_scope_binder helpers
- `ScalingGroupPermissionContext`, `ScalingGroupPermissionContextBuilder`
- legacy `models/rbac/__init__.py` scope types

## Depends on

BA-6048 (id column must exist). Recommended order: after BA-6050 so the FK schema is already id-based when RBAC mapping is migrated.

JIRA Issue: BA-6051

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.