Commit 05428d8d authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'instance-config-size-limits' into 'master'

Extend /help/instance_configuration with size limits

See merge request gitlab-org/gitlab!68284
parents ffedc13c 96630001
...@@ -13,7 +13,7 @@ class InstanceConfiguration ...@@ -13,7 +13,7 @@ class InstanceConfiguration
{ ssh_algorithms_hashes: ssh_algorithms_hashes, { ssh_algorithms_hashes: ssh_algorithms_hashes,
host: host, host: host,
gitlab_pages: gitlab_pages, gitlab_pages: gitlab_pages,
gitlab_ci: gitlab_ci, size_limits: size_limits,
package_file_size_limits: package_file_size_limits, package_file_size_limits: package_file_size_limits,
rate_limits: rate_limits }.deep_symbolize_keys rate_limits: rate_limits }.deep_symbolize_keys
end end
...@@ -38,11 +38,16 @@ class InstanceConfiguration ...@@ -38,11 +38,16 @@ class InstanceConfiguration
rescue Resolv::ResolvError rescue Resolv::ResolvError
end end
def gitlab_ci def size_limits
Settings.gitlab_ci {
.to_h max_attachment_size: application_settings[:max_attachment_size].megabytes,
.merge(artifacts_max_size: { value: Gitlab::CurrentSettings.max_artifacts_size.megabytes, receive_max_input_size: application_settings[:receive_max_input_size]&.megabytes,
default: 100.megabytes }) max_import_size: application_settings[:max_import_size] > 0 ? application_settings[:max_import_size].megabytes : nil,
diff_max_patch_bytes: application_settings[:diff_max_patch_bytes].bytes,
max_artifacts_size: application_settings[:max_artifacts_size].megabytes,
max_pages_size: application_settings[:max_pages_size] > 0 ? application_settings[:max_pages_size].megabytes : nil,
snippet_size_limit: application_settings[:snippet_size_limit]&.bytes
}
end end
def package_file_size_limits def package_file_size_limits
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
= render 'help/instance_configuration/ssh_info' = render 'help/instance_configuration/ssh_info'
= render 'help/instance_configuration/gitlab_pages' = render 'help/instance_configuration/gitlab_pages'
= render 'help/instance_configuration/gitlab_ci' = render 'help/instance_configuration/size_limits'
= render 'help/instance_configuration/package_registry' = render 'help/instance_configuration/package_registry'
= render 'help/instance_configuration/rate_limits' = render 'help/instance_configuration/rate_limits'
%p %p
......
- content_for :table_content do
%li= link_to _('GitLab CI'), '#gitlab-ci'
- content_for :settings_content do
%h2#gitlab-ci
= _('GitLab CI')
%p
= _('Below are the current settings regarding')
= succeed('.') { link_to(_('GitLab CI'), 'https://about.gitlab.com/gitlab-ci', target: '_blank') }
.table-responsive
%table
%thead
%tr
%th= _('Setting')
%th= instance_configuration_host(@instance_configuration.settings[:host])
%th= _('Default')
%tbody
%tr
- artifacts_size = @instance_configuration.settings[:gitlab_ci][:artifacts_max_size]
%td= _('Artifacts maximum size')
%td= instance_configuration_human_size_cell(artifacts_size[:value])
%td= instance_configuration_human_size_cell(artifacts_size[:default])
...@@ -28,8 +28,3 @@ ...@@ -28,8 +28,3 @@
%td= _('Port') %td= _('Port')
%td %td
%code= instance_configuration_cell_html(gitlab_pages[:port]) %code= instance_configuration_cell_html(gitlab_pages[:port])
%br
%p
- link_to_gitlab_ci = link_to(_('GitLab CI'), '#gitlab-ci')
= _("The maximum size of your Pages site is regulated by the artifacts maximum size which is part of %{link_to_gitlab_ci}.").html_safe % { link_to_gitlab_ci: link_to_gitlab_ci }
- size_limits = @instance_configuration.settings[:size_limits]
- content_for :table_content do
- if size_limits.present?
%li= link_to _('Size Limits'), '#size-limits'
- content_for :settings_content do
- if size_limits.present?
%h2#size-limits
= _('Size Limits')
%p
= _('There are several size limits in place.')
.table-responsive
%table
%thead
%tr
%th= _('Setting')
%th= instance_configuration_host(@instance_configuration.settings[:host])
%tbody
%tr
%td= _('Maximum attachment size')
%td= instance_configuration_human_size_cell(size_limits[:max_attachment_size])
%tr
%td= _('Maximum push size')
%td= instance_configuration_human_size_cell(size_limits[:receive_max_input_size])
%tr
%td= _('Maximum import size')
%td= instance_configuration_human_size_cell(size_limits[:max_import_size])
%tr
%td= _('Maximum diff patch size')
%td= instance_configuration_human_size_cell(size_limits[:diff_max_patch_bytes])
%tr
%td= _('Maximum job artifact size')
%td= instance_configuration_human_size_cell(size_limits[:max_artifacts_size])
%tr
%td= _('Maximum page size')
%td= instance_configuration_human_size_cell(size_limits[:max_pages_size])
%tr
%td= _('Maximum snippet size')
%td= instance_configuration_human_size_cell(size_limits[:snippet_size_limit])
...@@ -4531,9 +4531,6 @@ msgstr "" ...@@ -4531,9 +4531,6 @@ msgstr ""
msgid "Artifacts" msgid "Artifacts"
msgstr "" msgstr ""
msgid "Artifacts maximum size"
msgstr ""
msgid "As we continue to build more features for SAST, we'd love your feedback on the SAST configuration feature in %{linkStart}this issue%{linkEnd}." msgid "As we continue to build more features for SAST, we'd love your feedback on the SAST configuration feature in %{linkStart}this issue%{linkEnd}."
msgstr "" msgstr ""
...@@ -5138,9 +5135,6 @@ msgstr "" ...@@ -5138,9 +5135,6 @@ msgstr ""
msgid "Begin with the selected commit" msgid "Begin with the selected commit"
msgstr "" msgstr ""
msgid "Below are the current settings regarding"
msgstr ""
msgid "Below are the fingerprints for the current instance SSH host keys." msgid "Below are the fingerprints for the current instance SSH host keys."
msgstr "" msgstr ""
...@@ -10660,9 +10654,6 @@ msgstr "" ...@@ -10660,9 +10654,6 @@ msgstr ""
msgid "Decrease" msgid "Decrease"
msgstr "" msgstr ""
msgid "Default"
msgstr ""
msgid "Default CI/CD configuration file" msgid "Default CI/CD configuration file"
msgstr "" msgstr ""
...@@ -15233,9 +15224,6 @@ msgstr "" ...@@ -15233,9 +15224,6 @@ msgstr ""
msgid "GitLab Billing Team." msgid "GitLab Billing Team."
msgstr "" msgstr ""
msgid "GitLab CI"
msgstr ""
msgid "GitLab Import" msgid "GitLab Import"
msgstr "" msgstr ""
...@@ -20622,6 +20610,9 @@ msgstr "" ...@@ -20622,6 +20610,9 @@ msgstr ""
msgid "Maximum artifacts size (MB)" msgid "Maximum artifacts size (MB)"
msgstr "" msgstr ""
msgid "Maximum attachment size"
msgstr ""
msgid "Maximum attachment size (MB)" msgid "Maximum attachment size (MB)"
msgstr "" msgstr ""
...@@ -20640,6 +20631,9 @@ msgstr "" ...@@ -20640,6 +20631,9 @@ msgstr ""
msgid "Maximum delay (Minutes)" msgid "Maximum delay (Minutes)"
msgstr "" msgstr ""
msgid "Maximum diff patch size"
msgstr ""
msgid "Maximum diff patch size (Bytes)" msgid "Maximum diff patch size (Bytes)"
msgstr "" msgstr ""
...@@ -20667,9 +20661,15 @@ msgstr "" ...@@ -20667,9 +20661,15 @@ msgstr ""
msgid "Maximum files in a diff" msgid "Maximum files in a diff"
msgstr "" msgstr ""
msgid "Maximum import size"
msgstr ""
msgid "Maximum import size (MB)" msgid "Maximum import size (MB)"
msgstr "" msgstr ""
msgid "Maximum job artifact size"
msgstr ""
msgid "Maximum job timeout" msgid "Maximum job timeout"
msgstr "" msgstr ""
...@@ -20703,6 +20703,12 @@ msgstr "" ...@@ -20703,6 +20703,12 @@ msgstr ""
msgid "Maximum page reached" msgid "Maximum page reached"
msgstr "" msgstr ""
msgid "Maximum page size"
msgstr ""
msgid "Maximum push size"
msgstr ""
msgid "Maximum push size (MB)" msgid "Maximum push size (MB)"
msgstr "" msgstr ""
...@@ -20727,6 +20733,9 @@ msgstr "" ...@@ -20727,6 +20733,9 @@ msgstr ""
msgid "Maximum size of pages (MB)" msgid "Maximum size of pages (MB)"
msgstr "" msgstr ""
msgid "Maximum snippet size"
msgstr ""
msgid "Maximum time between updates that a mirror can have when scheduled to synchronize." msgid "Maximum time between updates that a mirror can have when scheduled to synchronize."
msgstr "" msgstr ""
...@@ -30949,6 +30958,9 @@ msgstr "" ...@@ -30949,6 +30958,9 @@ msgstr ""
msgid "Size" msgid "Size"
msgstr "" msgstr ""
msgid "Size Limits"
msgstr ""
msgid "Size limit per repository (MB)" msgid "Size limit per repository (MB)"
msgstr "" msgstr ""
...@@ -33337,9 +33349,6 @@ msgstr "" ...@@ -33337,9 +33349,6 @@ msgstr ""
msgid "The maximum number of tags that a single worker accepts for cleanup. If the number of tags goes above this limit, the list of tags to delete is truncated to this number. To remove this limit, set it to 0." msgid "The maximum number of tags that a single worker accepts for cleanup. If the number of tags goes above this limit, the list of tags to delete is truncated to this number. To remove this limit, set it to 0."
msgstr "" msgstr ""
msgid "The maximum size of your Pages site is regulated by the artifacts maximum size which is part of %{link_to_gitlab_ci}."
msgstr ""
msgid "The merge conflicts for this merge request cannot be resolved through GitLab. Please try to resolve them locally." msgid "The merge conflicts for this merge request cannot be resolved through GitLab. Please try to resolve them locally."
msgstr "" msgstr ""
...@@ -33637,6 +33646,9 @@ msgstr "" ...@@ -33637,6 +33646,9 @@ msgstr ""
msgid "There are several rate limits in place to protect the system." msgid "There are several rate limits in place to protect the system."
msgstr "" msgstr ""
msgid "There are several size limits in place."
msgstr ""
msgid "There is a halted Elasticsearch migration" msgid "There is a halted Elasticsearch migration"
msgstr "" msgstr ""
......
...@@ -76,24 +76,46 @@ RSpec.describe InstanceConfiguration do ...@@ -76,24 +76,46 @@ RSpec.describe InstanceConfiguration do
end end
end end
describe '#gitlab_ci' do describe '#size_limits' do
let(:gitlab_ci) { subject.settings[:gitlab_ci] } before do
Gitlab::CurrentSettings.current_application_settings.update!(
max_attachment_size: 10,
receive_max_input_size: 20,
max_import_size: 30,
diff_max_patch_bytes: 409600,
max_artifacts_size: 50,
max_pages_size: 60,
snippet_size_limit: 70
)
end
it 'returns Settings.gitalb_ci' do it 'returns size limits from application settings' do
gitlab_ci.delete(:artifacts_max_size) size_limits = subject.settings[:size_limits]
expect(gitlab_ci).to eq(Settings.gitlab_ci.symbolize_keys) expect(size_limits[:max_attachment_size]).to eq(10.megabytes)
expect(size_limits[:receive_max_input_size]).to eq(20.megabytes)
expect(size_limits[:max_import_size]).to eq(30.megabytes)
expect(size_limits[:diff_max_patch_bytes]).to eq(400.kilobytes)
expect(size_limits[:max_artifacts_size]).to eq(50.megabytes)
expect(size_limits[:max_pages_size]).to eq(60.megabytes)
expect(size_limits[:snippet_size_limit]).to eq(70.bytes)
end end
it 'returns the key artifacts_max_size' do it 'returns nil if receive_max_input_size not set' do
expect(gitlab_ci.keys).to include(:artifacts_max_size) Gitlab::CurrentSettings.current_application_settings.update!(receive_max_input_size: nil)
size_limits = subject.settings[:size_limits]
expect(size_limits[:receive_max_input_size]).to be_nil
end end
it 'returns the key artifacts_max_size with values' do it 'returns nil if set to 0 (unlimited)' do
stub_application_setting(max_artifacts_size: 200) Gitlab::CurrentSettings.current_application_settings.update!(max_import_size: 0, max_pages_size: 0)
size_limits = subject.settings[:size_limits]
expect(gitlab_ci[:artifacts_max_size][:default]).to eq(100.megabytes) expect(size_limits[:max_import_size]).to be_nil
expect(gitlab_ci[:artifacts_max_size][:value]).to eq(200.megabytes) expect(size_limits[:max_pages_size]).to be_nil
end end
end end
......
...@@ -9,6 +9,7 @@ RSpec.describe 'help/instance_configuration' do ...@@ -9,6 +9,7 @@ RSpec.describe 'help/instance_configuration' do
let(:ssh_settings) { settings[:ssh_algorithms_hashes] } let(:ssh_settings) { settings[:ssh_algorithms_hashes] }
before do before do
create(:plan, name: 'plan1', title: 'Plan 1')
assign(:instance_configuration, instance_configuration) assign(:instance_configuration, instance_configuration)
end end
...@@ -17,7 +18,9 @@ RSpec.describe 'help/instance_configuration' do ...@@ -17,7 +18,9 @@ RSpec.describe 'help/instance_configuration' do
expect(rendered).to have_link(nil, href: '#ssh-host-keys-fingerprints') if ssh_settings.any? expect(rendered).to have_link(nil, href: '#ssh-host-keys-fingerprints') if ssh_settings.any?
expect(rendered).to have_link(nil, href: '#gitlab-pages') expect(rendered).to have_link(nil, href: '#gitlab-pages')
expect(rendered).to have_link(nil, href: '#gitlab-ci') expect(rendered).to have_link(nil, href: '#size-limits')
expect(rendered).to have_link(nil, href: '#package-registry')
expect(rendered).to have_link(nil, href: '#rate-limits')
end end
it 'has several sections' do it 'has several sections' do
...@@ -25,7 +28,9 @@ RSpec.describe 'help/instance_configuration' do ...@@ -25,7 +28,9 @@ RSpec.describe 'help/instance_configuration' do
expect(rendered).to have_css('h2#ssh-host-keys-fingerprints') if ssh_settings.any? expect(rendered).to have_css('h2#ssh-host-keys-fingerprints') if ssh_settings.any?
expect(rendered).to have_css('h2#gitlab-pages') expect(rendered).to have_css('h2#gitlab-pages')
expect(rendered).to have_css('h2#gitlab-ci') expect(rendered).to have_css('h2#size-limits')
expect(rendered).to have_css('h2#package-registry')
expect(rendered).to have_css('h2#rate-limits')
end end
end 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