lablup / lablup/backend.ai

Relax Image Tag Format Validation

Open
#5,983 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

## Motivation

Currently, Backend.AI enforces overly strict image tag validation through the `rx_slug` regex pattern in `src/ai/backend/common/docker.py:563`. This pattern requires tags to start and end with alphanumeric characters, rejecting many valid Docker registry tags that use hyphens, underscores, or periods at the beginning or end. This causes compatibility issues when importing images from external registries like Docker Hub, Harbor, or ECR.

## Required Features

- **Relax** `rx_slug` pattern: Update the regex pattern to align with Docker registry tag specifications while maintaining basic format validation
- **Preserve basic validation**: Continue preventing truly invalid characters or formats that would break Backend.AI's internal processing
- **Maintain backward compatibility**: Ensure existing valid tags continue to work without changes
- **Error handling improvement**: Convert hard failures to warnings where appropriate, allowing image processing to continue
- **Support common tag patterns**: Enable tags with leading/trailing special characters within Docker spec limits

## Impact

### Primary Components

- `src/ai/backend/common/docker.py` - Core tag validation logic
- `src/ai/backend/common/exception.py` - InvalidImageTag exception handling
- `src/ai/backend/manager/registry/` - Registry scanning and synchronization modules

### Services Affected

- Manager service (image validation during imports)
- Registry scanners (automated image discovery)
- API endpoints that accept image references

## Testing Scenarios

### Valid Tag Acceptance Tests

- Verify tags like `pytorch-dev`, `tensorflow.gpu`, `cuda_11.8` are accepted
- Test Docker Hub standard patterns: `ubuntu:20.04-slim`, `node:16-alpine`
- Validate complex version tags: `python:3.9.18-slim-bookworm`

### Backward Compatibility Tests

- Ensure existing Backend.AI images continue to work
- Verify previously valid tags remain functional
- Test customized image tags don't break

JIRA Issue: BA-2458

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.