Commit a5a382a9 authored by Sean McGivern's avatar Sean McGivern

Make Pages disk access fail in web server

Previously, when `GITLAB_PAGES_DENY_DISK_ACCESS` was set, accessing
`Gitlab::Pages::Settings.path` from a web process would track an
exception and continue on.

Now it will simply raise the exception and fail. This is to make it
easier for developers to find a problem with their code before taking it
to production on GitLab.com, where the Pages NFS mount will soon be
removed.
parent 438aade5
......@@ -7,11 +7,7 @@ module Gitlab
def path
if ::Gitlab::Runtime.web_server? && ENV['GITLAB_PAGES_DENY_DISK_ACCESS'] == '1'
begin
raise DiskAccessDenied
rescue DiskAccessDenied => ex
::Gitlab::ErrorTracking.track_exception(ex)
end
raise DiskAccessDenied
end
super
......
......@@ -10,12 +10,6 @@ RSpec.describe Gitlab::Pages::Settings do
it { is_expected.to eq('the path') }
it 'does not track calls' do
expect(::Gitlab::ErrorTracking).not_to receive(:track_exception)
subject
end
context 'when running under a web server' do
before do
allow(::Gitlab::Runtime).to receive(:web_server?).and_return(true)
......@@ -23,24 +17,13 @@ RSpec.describe Gitlab::Pages::Settings do
it { is_expected.to eq('the path') }
it 'does not track calls' do
expect(::Gitlab::ErrorTracking).not_to receive(:track_exception)
subject
end
context 'with the env var' do
before do
stub_env('GITLAB_PAGES_DENY_DISK_ACCESS', '1')
end
it { is_expected.to eq('the path') }
it 'tracks a DiskAccessDenied exception' do
expect(::Gitlab::ErrorTracking).to receive(:track_exception)
.with(instance_of(described_class::DiskAccessDenied)).and_call_original
subject
it 'raises a DiskAccessDenied exception' do
expect { subject }.to raise_error(described_class::DiskAccessDenied)
end
end
end
......
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