Skip to content
GitLab
Next
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
GitLab
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
4
Snippets
Groups
Projects
Show more breadcrumbs
GitLab.org
GitLab
Commits
bdf36a78
Commit
bdf36a78
authored
1 year ago
by
Rutger Wessels
Browse files
Options
Downloads
Patches
Plain Diff
Add check for single db setup
parent
3d7c6fe0
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/gitlab/database/decomposition/migrate.rb
+15
-2
15 additions, 2 deletions
lib/gitlab/database/decomposition/migrate.rb
spec/lib/gitlab/database/decomposition/migrate_spec.rb
+13
-0
13 additions, 0 deletions
spec/lib/gitlab/database/decomposition/migrate_spec.rb
with
28 additions
and
2 deletions
lib/gitlab/database/decomposition/migrate.rb
+
15
−
2
View file @
bdf36a78
...
...
@@ -19,8 +19,9 @@ def initialize
end
def
process!
dump_main_db
if
required_diskspace_available
return
unless
can_migrate?
dump_main_db
import_dump_to_ci_db
FileUtils
.
remove_entry_secure
(
@backup_location
,
true
)
...
...
@@ -43,7 +44,7 @@ def diskspace_free
).
bytes_free
end
def
required_diskspace_available
def
required_diskspace_available
?
needed
=
main_table_sizes
*
1.25
available
=
diskspace_free
...
...
@@ -57,6 +58,18 @@ def required_diskspace_available
true
end
def
single_database_setup?
if
Gitlab
::
Database
.
database_mode
==
Gitlab
::
Database
::
MODE_MULTIPLE_DATABASES
raise
MigrateError
,
"GitLab is already configured to run on multiple databases"
end
true
end
def
can_migrate?
single_database_setup?
&&
required_diskspace_available?
end
def
with_transient_pg_env
(
extended_env
)
ENV
.
merge!
(
extended_env
)
result
=
yield
...
...
This diff is collapsed.
Click to expand it.
spec/lib/gitlab/database/decomposition/migrate_spec.rb
+
13
−
0
View file @
bdf36a78
...
...
@@ -73,5 +73,18 @@
)
end
end
context
'when already on decomposed setup'
do
before
do
allow
(
Gitlab
::
Database
).
to
receive
(
:database_mode
).
and_return
(
Gitlab
::
Database
::
MODE_MULTIPLE_DATABASES
)
end
it
'raises error'
do
expect
{
process
}.
to
raise_error
(
Gitlab
::
Database
::
Decomposition
::
MigrateError
,
"GitLab is already configured to run on multiple databases"
)
end
end
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment