Add images connection field to ContainerRegistryGQL node
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 15h 13m
- Merged PRs (30d)
- 368
Description
Background
`ContainerRegistryGQL` (`src/ai/backend/manager/api/gql/container_registry/types.py:48`) currently exposes registry metadata fields (`url`, `registry_name`, `type`, `project`, `username`, `password`, `ssl_verify`, `is_global`, `extra`) but has no way to navigate to the images that belong to the registry. Operators looking to delete or modify a registry have no GraphQL-visible way to discover the dependent `images` rows, which has led to dangling FK situations in production (registry removed while images still reference it, causing `_resolve_image_configs` to fail with `AttributeError: 'NoneType' object has no attribute 'url'` and stuck sessions). The legacy `ContainerRegistryNode` in `gql_legacy/container_registry.py:109` also lacks this — only `allowed_groups` is wired today.
Proposed Change
1. Add an `images` paginated connection field to `ContainerRegistryGQL` using the standard v2 connection pattern (cursor + offset pagination, filter, order_by).
2. Add an `ImageFilterDTO`-compatible filter argument so callers can narrow by canonical, architecture, or other image attributes.
3. Implement an `ImageContainerRegistryLoader` (DataLoader) keyed by `registry_id` to prevent N+1 when the field is selected over a connection of registries.
4. Resolver lives in `api/gql/container_registry/resolver.py` (create if needed) and calls the existing image adapter through `info.context.adapters.image`.
5. Mark the new field with `added_version=NEXT_RELEASE_VERSION` via `gql_added_field` / `BackendAIGQLMeta`.
Out of Scope
- Reverse direction `Image.registry` (covered by a separate story).
- Legacy `gql_legacy/container_registry.py:ContainerRegistryNode` — v2 only.
- Cascading delete / referential-integrity work for registry removal (separate story).
Acceptance Criteria
- `ContainerRegistryV2` GraphQL type exposes an `images` field returning `ImageConnection` (or equivalent v2 paginated connection).
- All standard pagination arguments are accepted: `filter`, `order_by`, `before`/`after`/`first`/`last`, `limit`/`offset`.
- DataLoader batching verified — selecting `images` over a connection of registries issues a single SQL query for all registry IDs.
- Filtering by canonical / architecture works through the new field.
- A unit test under `tests/manager/api/gql/container_registry/` covers basic field selection and DataLoader batching.
- Manual verification with `./bai` or a GraphQL client returns expected results for an admin user.
JIRA Issue: BA-6013
Contributor guide
Assessment
This issue has not been assessed yet.