lablup / lablup/backend.ai

Clean up the derived roles when a preset is deleted

Open
#14,256 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
670
Forks
183
Avg merge
15h 13m
Merged PRs (30d)
368

Description

2026-09-08 결정: 프리셋을 지우면 파생 역할도 지운다. 부여는 user_roles.role_id FK ON DELETE CASCADE(이미 있음), 권한 행은 permissions.role_id CASCADE로 따라 사라진다. 역할의 VE 노드·등재 에지는 DB FK가 없으므로 앱이 ops purge_entity(→ _teardown)로 역할마다 정리한다. 따라서 DB 캐스케이드(role_presets→roles)에 기대지 않고 프리셋 purge 경로가 파생 역할을 먼저 purge한 뒤 프리셋을 지운다. roles.role_preset_id의 SET NULL은 안전망으로 유지.

대응: 프리셋 soft-delete(deleted=true) → 파생 역할 status DELETED(부여 유지), restore → 역할 restore. 프리셋 purge → 파생 역할 purge(위 순서). BA-7681의 SYSTEM 가드는 사람의 수정·삭제를 막는 것이므로 프리셋 경로용 내부 purger는 가드를 타지 않는다.

미리보기: 사라질 역할 수와 user_roles 부여 수(유저 수)를 돌려주는 preview 액션. BA-7730 뒤 파생 역할 조회는 roles.role_preset_id + (scope_type, scope_id)로.

----

대상

- 프리셋이 사라지면 그 프리셋에서 나온 역할도 쓸 곳이 없다. 함께 정리한다.

- 관리자가 결과를 미리 볼 수 있어야 한다. 몇 명의 무엇이 사라지는지 알려 준 뒤 진행한다.

완료 기준

- 프리셋 삭제 후 그 프리셋에서 나온 역할이 남지 않는다.

열린 결정

- 그 역할을 갖고 있던 사람들의 부여를 어떻게 할지. 함께 거두면 접근이 즉시 끊기고, 남기면 주인 없는 부여가 된다.

JIRA Issue: BA-7684

Contributor guide

Open the contributing guide

Research direction

Trace the preset soft-delete, restore, and purge paths, starting with the internal ops purge_entity → _teardown flow and the roles.role_preset_id relationship. Confirm how derived roles and their user_roles assignments are found, then implement the requested preview and purge behavior; done means no derived roles remain after preset deletion while soft-delete and restore behavior matches the stated rules.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, authorization, backend, database
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.