lablup / lablup/backend.ai

vfolder: `list_hosts` returns a `default` host the user has no `CREATE_VFOLDER` permission on

Open
#12,593 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

## Summary

`GET /folders/_/hosts` can return a `default` host that the requesting user has **no `CREATE_VFOLDER` permission on**. The `default` computation only checks membership in `allowed_hosts`, which contains every host the user has *any* permission on — including mount-only / read-only hosts:

```python
# src/ai/backend/manager/services/vfolder/services/vfolder.py — VFolderService.list_hosts
default_host = self._config_provider.config.volumes.default_host
if default_host not in allowed_hosts:
default_host = None
```

So when `volumes.default_host` points to a host the user can mount but not create on, the API still advertises it as the default.

## Observed behavior

For a user whose permissions look like (host names genericized):

- `proxy-a:vol1` — create allowed
- `proxy-b:vol1`, `proxy-b:vol2`, `proxy-b:vol3` — mount-only (no `CREATE_VFOLDER`)

and `volumes.default_host = "proxy-b:vol1"`, the response is:

```json
{
"default": "proxy-b:vol1",
"allowed": ["proxy-a:vol1", "proxy-b:vol1", "proxy-b:vol2", "proxy-b:vol3"],
"volume_info": { "...": {} }
}
```

The `default` is a host the user cannot actually create a vfolder on.

## Impact

Clients preselect `default` in vfolder-creation forms. Now that per-host create permissions are queryable (`myStorageHostPermissions`, added in 26.4.2), permission-aware pickers must treat this preselection as invalid — the storage-host select then initializes **empty** (the invalid default is cleared by client-side gating), and without such gating, the preselection leads to a creation attempt that fails server-side.

## Proposal

Make `default` create-permission-aware in `list_hosts`. When the configured `volumes.default_host` does not grant `CREATE_VFOLDER` to the requesting user, either:

1. **Replace** it with the first (sorted) allowed host that does grant `CREATE_VFOLDER` — keeps clients simple, `default` stays "the host we recommend creating on"; or
2. **Discard** it (return `null`) — minimal change; clients already have to handle `null` (the existing `default_host not in allowed_hosts` branch).

Option 1 seems preferable since the field's only consumer purpose is preselecting a create target.

Related: #12333 (folding per-host permissions into the host-list response).

Contributor guide

Open the contributing guide

Research direction

Start in src/ai/backend/manager/services/vfolder/services/vfolder.py at VFolderService.list_hosts and inspect how allowed_hosts and CREATE_VFOLDER permissions are computed for GET /folders/_/hosts. Done when the response never selects a configured default host that the requesting user cannot create a vfolder on, while preserving valid create-capable defaults or fallback behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.