Commit 53d6f23e authored by Erick Bajao's avatar Erick Bajao

Remove flag and document plan limits

This removes the flag and adds documentation about the new
maximum file size limit per artifact type.
parent 35870d93
...@@ -303,16 +303,12 @@ module Ci ...@@ -303,16 +303,12 @@ module Ci
end end
def self.max_artifact_size(type:, project:) def self.max_artifact_size(type:, project:)
max_size = if Feature.enabled?(:ci_max_artifact_size_per_type, project, default_enabled: false) limit_name = "#{PLAN_LIMIT_PREFIX}#{type}"
limit_name = "#{PLAN_LIMIT_PREFIX}#{type}"
max_size = project.actual_limits.limit_for(
project.actual_limits.limit_for( limit_name,
limit_name, alternate_limit: -> { project.closest_setting(:max_artifacts_size) }
alternate_limit: -> { project.closest_setting(:max_artifacts_size) } )
)
else
project.closest_setting(:max_artifacts_size)
end
max_size&.megabytes.to_i max_size&.megabytes.to_i
end end
......
---
title: Remove flag and document max artifact size plan limits
merge_request: 37226
author:
type: changed
...@@ -314,6 +314,57 @@ To update this limit to a new value on a self-managed installation, run the foll ...@@ -314,6 +314,57 @@ To update this limit to a new value on a self-managed installation, run the foll
Plan.default.actual_limits.update!(ci_instance_level_variables: 30) Plan.default.actual_limits.update!(ci_instance_level_variables: 30)
``` ```
### Maximum file size per type of artifact
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/216097) in GitLab 13.3.
Artifacts that are uploaded by the Runner will be rejected if the file size exceeds the
maximum file size limit. The limit is determined by picking the smaller value between the project's
[maximum artifact size setting](../user/admin_area/settings/continuous_integration.md#maximum-artifacts-size-core-only)
and the plan limit for the given artifact type.
Values are interpreted as megabytes thus the smallest possible value that can be defined is `1 MB`.
Each type of artifact has its corresponding maximum size limit. For now, only the `lsif` type's plan limit
is enabled and has a default value defined. The rest of the values and defaults are going to be determined and updated
in future releases.
| Limit Name | Default Value |
| ----------------------------------------- | ------------- |
| ci_max_artifact_size_lsif | 20 |
| ci_max_artifact_size_archive | 0 |
| ci_max_artifact_size_metadata | 0 |
| ci_max_artifact_size_trace | 0 |
| ci_max_artifact_size_junit | 0 |
| ci_max_artifact_size_sast | 0 |
| ci_max_artifact_size_dependency_scanning | 0 |
| ci_max_artifact_size_container_scanning | 0 |
| ci_max_artifact_size_dast | 0 |
| ci_max_artifact_size_codequality | 0 |
| ci_max_artifact_size_license_management | 0 |
| ci_max_artifact_size_license_scanning | 0 |
| ci_max_artifact_size_performance | 0 |
| ci_max_artifact_size_metrics | 0 |
| ci_max_artifact_size_metrics_referee | 0 |
| ci_max_artifact_size_network_referee | 0 |
| ci_max_artifact_size_dotenv | 0 |
| ci_max_artifact_size_cobertura | 0 |
| ci_max_artifact_size_terraform | 0 |
| ci_max_artifact_size_accessibility | 0 |
| ci_max_artifact_size_cluster_applications | 0 |
| ci_max_artifact_size_secret_detection | 0 |
| ci_max_artifact_size_requirements | 0 |
| ci_max_artifact_size_coverage_fuzzing | 0 |
| ci_max_artifact_size_browser_performance | 0 |
| ci_max_artifact_size_load_performance | 0 |
To update the limit on a self-managed installation, run the following in the
[GitLab Rails console](troubleshooting/debug.md#starting-a-rails-console-session):
```ruby
Plan.default.actual_limits.update!(ci_max_artifact_size_junit: 10)
```
## Instance monitoring and metrics ## Instance monitoring and metrics
### Incident Management inbound alert limits ### Incident Management inbound alert limits
......
...@@ -529,11 +529,9 @@ RSpec.describe Ci::JobArtifact do ...@@ -529,11 +529,9 @@ RSpec.describe Ci::JobArtifact do
context 'when file type is supported' do context 'when file type is supported' do
let(:project_closest_setting) { 1024 } let(:project_closest_setting) { 1024 }
let(:artifact_type) { 'junit' } let(:artifact_type) { 'junit' }
let(:limit_name) { "#{described_class::PLAN_LIMIT_PREFIX}#{artifact_type}" }
before do let!(:plan_limits) { create(:plan_limits, :default_plan) }
stub_feature_flags(ci_max_artifact_size_per_type: flag_enabled)
allow(build.project).to receive(:closest_setting).with(:max_artifacts_size).and_return(project_closest_setting)
end
shared_examples_for 'basing off the project closest setting' do shared_examples_for 'basing off the project closest setting' do
it { is_expected.to eq(project_closest_setting.megabytes.to_i) } it { is_expected.to eq(project_closest_setting.megabytes.to_i) }
...@@ -543,49 +541,40 @@ RSpec.describe Ci::JobArtifact do ...@@ -543,49 +541,40 @@ RSpec.describe Ci::JobArtifact do
it { is_expected.to eq(max_size_for_type.megabytes.to_i) } it { is_expected.to eq(max_size_for_type.megabytes.to_i) }
end end
context 'and feature flag for custom max size per type is enabled' do before do
let(:flag_enabled) { true } allow(build.project).to receive(:closest_setting).with(:max_artifacts_size).and_return(project_closest_setting)
let(:limit_name) { "#{described_class::PLAN_LIMIT_PREFIX}#{artifact_type}" } end
let!(:plan_limits) { create(:plan_limits, :default_plan) }
context 'and plan limit is disabled for the given artifact type' do context 'and plan limit is disabled for the given artifact type' do
before do before do
plan_limits.update!(limit_name => 0) plan_limits.update!(limit_name => 0)
end end
it_behaves_like 'basing off the project closest setting' it_behaves_like 'basing off the project closest setting'
context 'and project closest setting results to zero' do context 'and project closest setting results to zero' do
let(:project_closest_setting) { 0 } let(:project_closest_setting) { 0 }
it { is_expected.to eq(0) } it { is_expected.to eq(0) }
end
end end
end
context 'and plan limit is enabled for the given artifact type' do context 'and plan limit is enabled for the given artifact type' do
before do before do
plan_limits.update!(limit_name => max_size_for_type) plan_limits.update!(limit_name => max_size_for_type)
end end
context 'and plan limit is smaller than project setting' do
let(:max_size_for_type) { project_closest_setting - 1 }
it_behaves_like 'basing off the plan limit'
end
context 'and plan limit is smaller than project setting' do context 'and plan limit is smaller than project setting' do
let(:max_size_for_type) { project_closest_setting + 1 } let(:max_size_for_type) { project_closest_setting - 1 }
it_behaves_like 'basing off the project closest setting' it_behaves_like 'basing off the plan limit'
end
end end
end
context 'and feature flag for custom max size per type is disabled' do context 'and plan limit is smaller than project setting' do
let(:flag_enabled) { false } let(:max_size_for_type) { project_closest_setting + 1 }
it_behaves_like 'basing off the project closest setting' it_behaves_like 'basing off the project closest setting'
end
end end
end end
end end
...@@ -597,7 +586,8 @@ RSpec.describe Ci::JobArtifact do ...@@ -597,7 +586,8 @@ RSpec.describe Ci::JobArtifact do
Please refer to https://docs.gitlab.com/ee/development/application_limits.html on how to add new plan limit columns. Please refer to https://docs.gitlab.com/ee/development/application_limits.html on how to add new plan limit columns.
Take note that while existing max size plan limits default to 0, succeeding new limits are recommended to have Take note that while existing max size plan limits default to 0, succeeding new limits are recommended to have
non-zero default values. non-zero default values. Also, remember to update the plan limits documentation (doc/administration/instance_limits.md)
when changes or new entries are made.
MSG MSG
end end
end end
...@@ -1632,25 +1632,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do ...@@ -1632,25 +1632,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
stub_application_setting(max_artifacts_size: application_max_size) stub_application_setting(max_artifacts_size: application_max_size)
end end
context 'and feature flag ci_max_artifact_size_per_type is enabled' do it_behaves_like 'failed request'
before do
stub_feature_flags(ci_max_artifact_size_per_type: true)
end
it_behaves_like 'failed request'
end
context 'and feature flag ci_max_artifact_size_per_type is disabled' do
before do
stub_feature_flags(ci_max_artifact_size_per_type: false)
end
it 'bases of project closest setting' do
send_request
expect(response).to have_gitlab_http_status(success_code)
end
end
end end
context 'based on application setting' do context 'based on application setting' 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