Commit 1caef3c3 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'eb-document-artifact-size-plan-limits' into 'master'

Remove flag and document max artifact size plan limits

See merge request gitlab-org/gitlab!37226
parents 4c942812 96e3d404
......@@ -303,16 +303,12 @@ module Ci
end
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}"
project.actual_limits.limit_for(
max_size = project.actual_limits.limit_for(
limit_name,
alternate_limit: -> { project.closest_setting(:max_artifacts_size) }
)
else
project.closest_setting(:max_artifacts_size)
end
max_size&.megabytes.to_i
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
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
### Incident Management inbound alert limits
......
......@@ -529,11 +529,9 @@ RSpec.describe Ci::JobArtifact do
context 'when file type is supported' do
let(:project_closest_setting) { 1024 }
let(:artifact_type) { 'junit' }
let(:limit_name) { "#{described_class::PLAN_LIMIT_PREFIX}#{artifact_type}" }
before do
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
let!(:plan_limits) { create(:plan_limits, :default_plan) }
shared_examples_for 'basing off the project closest setting' do
it { is_expected.to eq(project_closest_setting.megabytes.to_i) }
......@@ -543,11 +541,9 @@ RSpec.describe Ci::JobArtifact do
it { is_expected.to eq(max_size_for_type.megabytes.to_i) }
end
context 'and feature flag for custom max size per type is enabled' do
let(:flag_enabled) { true }
let(:limit_name) { "#{described_class::PLAN_LIMIT_PREFIX}#{artifact_type}" }
let!(:plan_limits) { create(:plan_limits, :default_plan) }
before do
allow(build.project).to receive(:closest_setting).with(:max_artifacts_size).and_return(project_closest_setting)
end
context 'and plan limit is disabled for the given artifact type' do
before do
......@@ -574,20 +570,13 @@ RSpec.describe Ci::JobArtifact do
it_behaves_like 'basing off the plan limit'
end
context 'and plan limit is smaller than project setting' do
context 'and plan limit is larger than project setting' do
let(:max_size_for_type) { project_closest_setting + 1 }
it_behaves_like 'basing off the project closest setting'
end
end
end
context 'and feature flag for custom max size per type is disabled' do
let(:flag_enabled) { false }
it_behaves_like 'basing off the project closest setting'
end
end
end
def file_type_limit_failure_message(type, limit_name)
......@@ -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.
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
end
end
......@@ -1632,27 +1632,9 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
stub_application_setting(max_artifacts_size: application_max_size)
end
context 'and feature flag ci_max_artifact_size_per_type is enabled' do
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
context 'based on application setting' do
before do
stub_application_setting(max_artifacts_size: sample_max_size)
......
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