lablup / lablup/backend.ai

Add host_permission filter to VFolder my_search

Open
#10,672 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

Add a host_permission filter to the VFolder my_search query pipeline that filters vfolders by storage host accessibility based on the user's allowed_vfolder_hosts (domain + groups + keypair_resource_policy).

Scope:
- Add VFolderHostPermissionField StrEnum and HostPermissionFilter DTO (in_/not_in pattern matching VFolderStatusFilter) to common/dto/manager/v2/vfolder/types.py
- Add host_permission: HostPermissionFilter | None field to VFolderFilter DTO
- Add VFolderConditions.by_host_permission(user_id, domain_name, permissions, negate) -> QueryCondition
- SQL subquery using jsonb_each() + @> permission containment across 3 sources (domains, groups, keypair_resource_policies)
- UNION of all sources, VFolderRow.host.in_(subquery)
- Wire host_permission filter conversion in VFolderAdapter._convert_vfolder_filter() with current_user() context injection
- Comprehensive tests covering domain isolation, group membership differences, permission value filtering, shared vfolders, pagination

Design reference: my_vfolder_filter_plan.md sections 3.1-3.3, 5.1-5.3, 6.6-6.7, 7.2

RBAC note: Implementation encapsulated in QueryCondition boundary so internal data source can migrate from JSONB -> BEP-1052 Policy -> RBAC table without Adapter changes.

## Success Criteria
- [ ] HostPermissionFilter DTO with in_/not_in fields follows VFolderStatusFilter pattern
- [ ] host_permission.in_=["CREATE"] returns only vfolders on hosts where user has create-vfolder permission
- [ ] host_permission.not_in_=["CREATE"] returns only vfolders on hosts where user lacks create-vfolder permission
- [ ] Domain isolation: user in domain-alpha sees only alpha's allowed hosts, not beta's
- [ ] Group membership: users in different groups see different host sets
- [ ] Permission value filtering: host registered but lacking requested permission is excluded (e.g., mount-only host excluded from CREATE filter)
- [ ] Shared vfolders: included/excluded based on requester's host permissions, not owner's
- [ ] Empty allowed_vfolder_hosts ({}) produces empty result for in_ filter
- [ ] host_permission filter works with pagination (correct total_count, has_next_page)
- [ ] host_permission filter combines correctly with other filters (host string, cloneable, etc.)
- [ ] Omitting host_permission filter returns all vfolders (existing behavior unchanged)
- [ ] pants test passes for affected packages

JIRA Issue: BA-5506

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.