Commit e3ff928c authored by Bob Van Landuyt's avatar Bob Van Landuyt

Describe workaround when restore fails because of `Errno::EBUSY`

When `Errno::EBUSY` is raised during restore, this could indicate that
the directory being restored into is a mountpoint. In this case we
explain the user how to retry the restore.
parent effda09e
...@@ -53,6 +53,8 @@ module Backup ...@@ -53,6 +53,8 @@ module Backup
FileUtils.mv(files, timestamped_files_path) FileUtils.mv(files, timestamped_files_path)
rescue Errno::EACCES rescue Errno::EACCES
access_denied_error(app_files_dir) access_denied_error(app_files_dir)
rescue Errno::EBUSY
resource_busy_error(app_files_dir)
end end
end end
end end
......
...@@ -13,5 +13,19 @@ module Backup ...@@ -13,5 +13,19 @@ module Backup
EOS EOS
raise message raise message
end end
def resource_busy_error(path)
message = <<~EOS
### NOTICE ###
As part of restore, the task tried to rename `#{path}` before restoring.
This could not be completed, perhaps `#{path}` is a mountpoint?
To complete the restore, please move the contents of `#{path}` to a
different location and run the restore task again.
EOS
raise message
end
end end
end end
...@@ -81,6 +81,8 @@ module Backup ...@@ -81,6 +81,8 @@ module Backup
FileUtils.mv(files, bk_repos_path) FileUtils.mv(files, bk_repos_path)
rescue Errno::EACCES rescue Errno::EACCES
access_denied_error(path) access_denied_error(path)
rescue Errno::EBUSY
resource_busy_error(path)
end end
end end
end end
......
...@@ -62,5 +62,19 @@ describe Backup::Files do ...@@ -62,5 +62,19 @@ describe Backup::Files do
subject.restore subject.restore
end end
end end
describe 'folders that are a mountpoint' do
before do
allow(FileUtils).to receive(:mv).and_raise(Errno::EBUSY)
allow(subject).to receive(:run_pipeline!).and_return(true)
end
it 'shows error message' do
expect(subject).to receive(:resource_busy_error).with("/var/gitlab-registry")
.and_call_original
expect { subject.restore }.to raise_error(/is a mountpoint/)
end
end
end end
end end
...@@ -81,6 +81,18 @@ describe Backup::Repository do ...@@ -81,6 +81,18 @@ describe Backup::Repository do
subject.restore subject.restore
end end
end end
describe 'folder that is a mountpoint' do
before do
allow(FileUtils).to receive(:mv).and_raise(Errno::EBUSY)
end
it 'shows error message' do
expect(subject).to receive(:resource_busy_error).and_call_original
expect { subject.restore }.to raise_error(/is a mountpoint/)
end
end
end end
describe '#empty_repo?' do describe '#empty_repo?' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment