Skip to content
Snippets Groups Projects
Commit c765aa15b3a6 authored by Rutger Wessels's avatar Rutger Wessels
Browse files

Override default timeout when running decomposition migration

The default timeout is 5 minutes. But the migration can take
a lot of time. So we set it to 1 day.

Changelog: fixed
parent 79e3ff74a826
No related branches found
No related tags found
1 merge request!137Remerge after conversion fixups
......@@ -96,7 +96,7 @@
def run_migration
puts "Copying data to new database..."
run_command("gitlab-rake gitlab:db:decomposition:migrate")
run_command("gitlab-rake gitlab:db:decomposition:migrate", timeout: 84_600)
end
def post_migrate
......@@ -109,8 +109,8 @@
run_command("gitlab-ctl restart")
end
def run_command(cmd)
GitlabCtl::Util.run_command(cmd).tap do |status|
def run_command(cmd, timeout: nil)
GitlabCtl::Util.run_command(cmd, timeout: timeout).tap do |status|
if status.error?
enable_background_migrations unless background_migrations_initally_disabled?
......
......@@ -45,5 +45,5 @@
context 'when external command fails' do
before do
allow(GitlabCtl::Util).to receive(:run_command).and_return(command_fail)
allow(GitlabCtl::Util).to receive(:run_command).with(any_args).and_return(command_fail)
allow(GitlabCtl::Util).to receive(:run_command).with(
......@@ -49,8 +49,9 @@
allow(GitlabCtl::Util).to receive(:run_command).with(
"gitlab-rails runner \"Feature.enable(:execute_background_migrations) && Feature.enable(:execute_batched_migrations_on_schedule)\"\n"
"gitlab-rails runner \"Feature.enable(:execute_background_migrations) && Feature.enable(:execute_batched_migrations_on_schedule)\"\n",
timeout: nil
).and_return(command_ok)
end
context 'and background migrations are enabled before starting this script' do
it 'enables background migrations and then exits' do
expect(GitlabCtl::Util).to receive(:run_command).with(
......@@ -51,10 +52,11 @@
).and_return(command_ok)
end
context 'and background migrations are enabled before starting this script' do
it 'enables background migrations and then exits' do
expect(GitlabCtl::Util).to receive(:run_command).with(
"gitlab-rails runner \"Feature.enable(:execute_background_migrations) && Feature.enable(:execute_batched_migrations_on_schedule)\"\n"
"gitlab-rails runner \"Feature.enable(:execute_background_migrations) && Feature.enable(:execute_batched_migrations_on_schedule)\"\n",
timeout: nil
).and_return(command_ok)
expect { instance.migrate! }.to raise_error(SystemExit)
......@@ -76,9 +78,9 @@
context 'runs commands needed for migration to decomposed setup' do
before do
allow(GitlabCtl::Util).to receive(:run_command).and_return(command_ok)
allow(GitlabCtl::Util).to receive(:run_command).with(any_args).and_return(command_ok)
end
context 'and background migrations are enabled before starting this script' do
it 'disables background migrations' do
expect(GitlabCtl::Util).to receive(:run_command).with(
......@@ -80,9 +82,10 @@
end
context 'and background migrations are enabled before starting this script' do
it 'disables background migrations' do
expect(GitlabCtl::Util).to receive(:run_command).with(
"gitlab-rails runner \"Feature.disable(:execute_background_migrations) && Feature.disable(:execute_batched_migrations_on_schedule)\"\n"
"gitlab-rails runner \"Feature.disable(:execute_background_migrations) && Feature.disable(:execute_batched_migrations_on_schedule)\"\n",
timeout: nil
).and_return(command_ok)
instance.migrate!
......@@ -103,11 +106,12 @@
it 'stops Gitlab except for PostgreSQL' do
expect(GitlabCtl::Util).to receive(:run_command).with(
"gitlab-ctl stop && gitlab-ctl start postgresql"
).and_return(command_ok)
"gitlab-ctl stop && gitlab-ctl start postgresql",
timeout: nil
).and_return(command_ok).once
instance.migrate!
end
it 'calls the migration rake task' do
expect(GitlabCtl::Util).to receive(:run_command).with(
......@@ -108,14 +112,15 @@
instance.migrate!
end
it 'calls the migration rake task' do
expect(GitlabCtl::Util).to receive(:run_command).with(
"gitlab-rake gitlab:db:decomposition:migrate"
).and_return(command_ok)
"gitlab-rake gitlab:db:decomposition:migrate",
timeout: 84_600
).and_return(command_ok).once
instance.migrate!
end
it 'runs the reconfigure task' do
expect(GitlabCtl::Util).to receive(:run_command).with(
......@@ -116,14 +121,15 @@
instance.migrate!
end
it 'runs the reconfigure task' do
expect(GitlabCtl::Util).to receive(:run_command).with(
"gitlab-ctl reconfigure"
).and_return(command_ok)
"gitlab-ctl reconfigure",
timeout: nil
).and_return(command_ok).once
instance.migrate!
end
it 'enables write locks' do
expect(GitlabCtl::Util).to receive(:run_command).with(
......@@ -124,14 +130,15 @@
instance.migrate!
end
it 'enables write locks' do
expect(GitlabCtl::Util).to receive(:run_command).with(
"gitlab-rake gitlab:db:lock_writes"
).and_return(command_ok)
"gitlab-rake gitlab:db:lock_writes",
timeout: nil
).and_return(command_ok).once
instance.migrate!
end
it 'restarts GitLab' do
expect(GitlabCtl::Util).to receive(:run_command).with(
......@@ -132,11 +139,12 @@
instance.migrate!
end
it 'restarts GitLab' do
expect(GitlabCtl::Util).to receive(:run_command).with(
"gitlab-ctl restart"
).and_return(command_ok)
"gitlab-ctl restart",
timeout: nil
).and_return(command_ok).once
instance.migrate!
end
......@@ -144,8 +152,9 @@
context 'and background migrations are enabled before starting this script' do
it 'enables background migrations' do
expect(GitlabCtl::Util).to receive(:run_command).with(
"gitlab-rails runner \"Feature.enable(:execute_background_migrations) && Feature.enable(:execute_batched_migrations_on_schedule)\"\n"
).and_return(command_ok)
"gitlab-rails runner \"Feature.enable(:execute_background_migrations) && Feature.enable(:execute_batched_migrations_on_schedule)\"\n",
timeout: nil
).and_return(command_ok).once
instance.migrate!
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment