Add /gitlab/v1 API endpoints for batched background migration management

Summary

Add new API endpoints to the container-registry's /gitlab/v1 API to enable chatops-based management of batched background migrations (BBMs). This will allow the Container Registry team to manage BBMs without requiring direct access to production environments.

Background

We initially planned to use CLI in chatops CI/CD to manage BBMs.

The Database Operations team had security concerns about exposing direct database access to CI/CD runners for chatops automation though. So a decision was made to expose BBM management functionality through the existing /gitlab/v1 API instead and call the API endpoint in chatops repo instead

Required API Endpoints

The following operations need to be exposed via API:

  1. List batched background migrations - Query batched_background_migrations table
  2. Get BBM status - Query status of specific migration(s)
  3. Update BBM status - Update the status column in batched_background_migrations table
  4. Query BBM jobs (optional for now) - Query batched_background_migration_jobs table for detailed job information

Implementation Notes

  • The CLI commands can remain as-is for SRE debugging purposes (direct DB access from registry pods)
  • API endpoints will wrap the same DB queries currently used by CLI, minimizing code duplication
  • Authentication will use the existing /jwt/auth token mechanism with appropriate scopes
Edited by Pawel Rozlach