Default registry database port to postgresql['port']

What does this MR do?

The container registry database only derived its host from the embedded PostgreSQL settings, leaving the port pinned to the hardcoded attribute default of 5432. When postgresql['port'] was changed (e.g. to 5433), the registry still tried to connect on 5432, breaking fresh installs at the registry database migration step — now that the registry database is preferred by default (!9330 (merged)):

FATAL: RuntimeError: registry_database_migrations[registry] (registry::database_migrations line 20) had an error: RuntimeError: PostgreSQL did not respond before service checks were exhausted

This makes the registry the only DB-connecting component that did not follow postgresql['port']. gitlab_rails['db_port'] already falls back to postgresql['port'] via Gitlab::Rails.parse_database_settings.

This MR makes Registry.parse_database_configuration fall back to postgresql['port'] (then the node default) for the registry database port when the user has not explicitly set registry['database']['port'], mirroring how the host is derived. Users can still override the port explicitly.

Closes #9918 (closed)

How to reproduce locally

In /etc/gitlab/gitlab.rb, add:

postgresql['listen_address'] = '0.0.0.0'
postgresql['port'] = 5433
postgresql['trust_auth_cidr_addresses'] = ['127.0.0.1/32']

Then run gitlab-ctl reconfigure.

Checklist

Required

  • MR title and description are up to date, accurate, and descriptive.
  • MR targeting the appropriate branch.
  • Latest Merge Result pipeline is green.
  • When ready for review, MR is labeled workflowready for review per the Distribution MR workflow.
  • The UBT version and corresponding checksum hash have been updated and referenced in the merge request if applicable. (N/A — no UBT change.)

Expected

  • Tests added.
  • Documentation created/updated.
Edited by João Alexandre Cunha

Merge request reports

Loading