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-packagejobs have a green pipeline running against latest commit. -
Ifconfig/softwareorconfig/patchesdirectories are changed, make sure thebuild-package-on-all-osjob within theTrigger:ee-packagedownstream pipeline succeeded. -
If you are changing anything SSL related, then theTrigger:package:fipsmanual job within theTrigger:ee-packagedownstream pipeline must succeed. -
If CI configuration is changed, the branch must be pushed todev.gitlab.orgto 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 integer10, duration10s, URIscheme://user:passwd@host:portmay require quotation or other special handling when rendered in a template and written to a configuration file.