Skip to content

Add database readiness check to registry migrations

What does this MR do?

Add database readiness check to registry migrations

Adds resilience to wait a bit for the PostgreSQL server to be ready before running registry migrations. This is important specially on container registry restarts when the PostgreSQL server lives within the same container.

During container restarts the registry migration is called too early during container startup, since other previous task will be faster than during an usual fresh first time container install, since on fresh installs much more actions are called, like file creations for instance, which will persist on volumes during a container restart and do not need to be redone. Probably many more other things are cached on the volumes and not retriggered on container restart.

Therefore, in these cases, there isn't time enough for PostgreSQL to be up before the registry migration is called. And since the registry migrations are called as part of the main gitlab-ctl reconfigure, if this fails the whole reconfigure fails, which is per Omnibus fail-fast design. This results then in the container being forever restarting.

Solution

Technically this adds the RegistryPgHelper class to override the connection_info method from PgHelper, as in separate nodes we can't use the Rails connection string to do this check. Then we make use of the is_ready? implementation to validate that PostgreSQL server is ready to take connections. This method does a few retries before failing and is also configurable.

Issue: gitlab#571936 Changelog: fixed

Related issues

Closes Docker version GitLab 18.3/18.4 crash when rest... (gitlab#571936)

Checklist

See Definition of done.

For anything in this list which will not be completed, please provide a reason in the MR discussion.

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.

For GitLab team members

If you don't have access to this, the reviewer should trigger these jobs for you during the review process.

  • The manual Trigger:ee-package jobs have a green pipeline running against latest commit.
  • If config/software or config/patches directories are changed, make sure the build-package-on-all-os job within the Trigger:ee-package downstream pipeline succeeded.
  • If you are changing anything SSL related, then the Trigger:package:fips manual job within the Trigger:ee-package downstream pipeline must succeed.
  • If CI configuration is changed, the branch must be pushed to dev.gitlab.org to confirm regular branch builds aren't broken.

Expected (please provide an explanation if not completing)

  • Test plan indicating conditions for success has been posted and passes.
  • Documentation created/updated.
  • Tests added.
  • Integration tests added to GitLab QA.
  • Equivalent MR/issue for the GitLab Chart opened.
  • Validate potential values for new configuration settings. Formats such as integer 10, duration 10s, URI scheme://user:passwd@host:port may require quotation or other special handling when rendered in a template and written to a configuration file.
Edited by João Alexandre Cunha

Merge request reports

Loading