Skip to content

Registry migrations need to consider custom registry directory location

What

We allow users to deploy the registry on custom location, via registry['dir'] = "/var/opt/gitlab/registry-2".

But our registry database migration command expects the default location registry['dir'] = "/var/opt/gitlab/registry": https://gitlab.com/gitlab-org/omnibus-gitlab/-/blob/1196174d9423c89b524ecfb0ad851307ab1b2440/files/gitlab-ctl-commands/lib/gitlab_ctl/registry/database.rb#L11

We should be custom location aware when running migrations.

Reproducing the error

docker-compose.yml
services:
  gitlab-18-5-0:
    image: gitlab/gitlab-ce:18.5.0-ce.0
    container_name: gitlab-test-18-5-0
    hostname: gitlab.local
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://gitlab.local'
        letsencrypt['enable'] = false
        
        # Enable registry with database
        registry_external_url 'http://gitlab.local:5100'
        registry['database'] = {
          'enabled' => true,
          'host' => '/var/opt/gitlab/postgresql',
          'port' => 5432,
          'user' => 'registry',
          'password' => 'toomanysecrets',
          'dbname' => 'registry',
          'sslmode' => 'disable'
        }
        registry['dir'] = "/var/opt/gitlab/registry-2"
        
        # Disable some services to speed up testing (only valid options for 18.2.8)
        prometheus_monitoring['enable'] = false
        
        # Reduce resource usage
        puma['worker_processes'] = 2
        sidekiq['max_concurrency'] = 10
    ports:
      - "8080:80"
      - "5100:5100"
      - "2222:22"
    volumes:
      - gitlab_config:/etc/gitlab
      - gitlab_logs:/var/log/gitlab
      - gitlab_data:/var/opt/gitlab
    networks:
      - gitlab_network
    shm_size: '256m'
    restart: unless-stopped
    profiles:
      - v18-5-0

volumes:
  gitlab_config:
    driver: local
  gitlab_logs:
    driver: local
  gitlab_data:
    driver: local

networks:
  gitlab_network:
    driver: bridge

The above docker-compose will fail the reconfigure with:

unning handlers:
[2025-11-04T21:11:09+00:00] ERROR: Running exception handlers
There was an error running gitlab-ctl reconfigure:

registry_database_migrations[registry] (registry::database_migrations line 19) had an error: Mixlib::ShellOut::ShellCommandFailed: bash_hide_env[migrate registry database: registry] (registry::database_migrations line 15) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of "bash"  ----
STDOUT: Running migrate up
Could not find '/var/opt/gitlab/registry/config.yml' file. Is this command being run on a Container Registry node?
STDERR:
---- End output of "bash"  ----
Ran "bash"  returned 1

Running handlers complete
[2025-11-04T21:11:09+00:00] ERROR: Exception handlers complete
Infra Phase failed. 23 resources updated in 05 seconds
[2025-11-04T21:11:09+00:00] FATAL: Stacktrace dumped to /opt/gitlab/embedded/cookbooks/cache/cinc-stacktrace.out
[2025-11-04T21:11:09+00:00] FATAL: ---------------------------------------------------------------------------------------
[2025-11-04T21:11:09+00:00] FATAL: PLEASE PROVIDE THE CONTENTS OF THE stacktrace.out FILE (above) IF YOU FILE A BUG REPORT
[2025-11-04T21:11:09+00:00] FATAL: ---------------------------------------------------------------------------------------
[2025-11-04T21:11:09+00:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: registry_database_migrations[registry] (registry::database_migrations line 19) had an error: Mixlib::ShellOut::ShellCommandFailed: bash_hide_env[migrate registry database: registry] (registry::database_migrations line 15) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of "bash"  ----
STDOUT: Running migrate up
Could not find '/var/opt/gitlab/registry/config.yml' file. Is this command being run on a Container Registry node?