Commit 972c82a1 authored by Matthias Käppler's avatar Matthias Käppler

Merge branch 'mc/feature/pipeline-trigger-application-limits' into 'master'

Implement pipeline trigger application limits

See merge request gitlab-org/gitlab!73985
parents 0e31f5f4 e7b6e65a
......@@ -3,6 +3,10 @@
module Ci
class Trigger < Ci::ApplicationRecord
include Presentable
include Limitable
self.limit_name = 'pipeline_triggers'
self.limit_scope = :project
belongs_to :project
belongs_to :owner, class_name: "User"
......
# frozen_string_literal: true
class CreatePipelineTriggersApplicationLimits < Gitlab::Database::Migration[1.0]
def change
add_column(:plan_limits, :pipeline_triggers, :integer, default: 25_000, null: false)
end
end
# frozen_string_literal: true
class InsertPipelineTriggersApplicationLimits < Gitlab::Database::Migration[1.0]
def up
create_or_update_plan_limit('pipeline_triggers', 'default', 0)
create_or_update_plan_limit('pipeline_triggers', 'free', 25_000)
create_or_update_plan_limit('pipeline_triggers', 'opensource', 0)
create_or_update_plan_limit('pipeline_triggers', 'premium', 0)
create_or_update_plan_limit('pipeline_triggers', 'premium_trial', 0)
create_or_update_plan_limit('pipeline_triggers', 'ultimate', 0)
create_or_update_plan_limit('pipeline_triggers', 'ultimate_trial', 0)
end
def down
create_or_update_plan_limit('pipeline_triggers', 'default', 0)
create_or_update_plan_limit('pipeline_triggers', 'free', 0)
create_or_update_plan_limit('pipeline_triggers', 'opensource', 0)
create_or_update_plan_limit('pipeline_triggers', 'premium', 0)
create_or_update_plan_limit('pipeline_triggers', 'premium_trial', 0)
create_or_update_plan_limit('pipeline_triggers', 'ultimate', 0)
create_or_update_plan_limit('pipeline_triggers', 'ultimate_trial', 0)
end
end
024c123bf06b796341a22e54f4c34b967d84aeb9b2006acf5cfef96a6161c13d
\ No newline at end of file
03842b87c4118f0e2aba1597ff08a6830b1dd5442a455e4bc9774b93b36a09b5
\ No newline at end of file
......@@ -17577,7 +17577,8 @@ CREATE TABLE plan_limits (
dast_profile_schedules integer DEFAULT 1 NOT NULL,
external_audit_event_destinations integer DEFAULT 5 NOT NULL,
dotenv_variables integer DEFAULT 20 NOT NULL,
dotenv_size integer DEFAULT 5120 NOT NULL
dotenv_size integer DEFAULT 5120 NOT NULL,
pipeline_triggers integer DEFAULT 25000 NOT NULL
);
CREATE SEQUENCE plan_limits_id_seq
......@@ -390,6 +390,27 @@ Plan.default.actual_limits.update!(ci_project_subscriptions: 500)
Set the limit to `0` to disable it.
### Limit the number of pipeline triggers
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/33696) in GitLab 14.6.
You can set a limit on the maximum number of pipeline triggers per project. This
limit is checked every time a new trigger is created.
If a new trigger would cause the total number of pipeline triggers to exceed the
limit, the trigger is considered invalid.
Set the limit to `0` to disable it. Defaults to `0` on self-managed instances.
To set this limit to `100` on a self-managed installation, run the following in the
[GitLab Rails console](operations/rails_console.md#starting-a-rails-console-session):
```ruby
Plan.default.actual_limits.update!(pipeline_triggers: 100)
```
This limit is [enabled on GitLab.com](../user/gitlab_com/index.md#gitlab-cicd).
### Number of pipeline schedules
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/29566) in GitLab 12.10.
......
......@@ -135,6 +135,7 @@ the related documentation.
| Scheduled Pipeline Cron | `*/5 * * * *` | `3-59/10 * * * *` |
| [Max jobs in active pipelines](../../administration/instance_limits.md#number-of-jobs-in-active-pipelines) | `500` for Free tier, unlimited otherwise | Unlimited |
| [Max CI/CD subscriptions to a project](../../administration/instance_limits.md#number-of-cicd-subscriptions-to-a-project) | `2` | Unlimited |
| [Max number of pipeline triggers in a project](../../administration/instance_limits.md#limit-the-number-of-pipeline-triggers) | `25000` for Free tier, Unlimited for all paid tiers | Unlimited |
| [Max pipeline schedules in projects](../../administration/instance_limits.md#number-of-pipeline-schedules) | `10` for Free tier, `50` for all paid tiers | Unlimited |
| [Max pipelines per schedule](../../administration/instance_limits.md#limit-the-number-of-pipelines-created-by-a-pipeline-schedule-per-day) | `24` for Free tier, `288` for all paid tiers | Unlimited |
| [Scheduled Job Archival](../../user/admin_area/settings/continuous_integration.md#archive-jobs) | 3 months | Never |
......
......@@ -57,4 +57,8 @@ RSpec.describe Ci::Trigger do
it { is_expected.to eq(false) }
end
end
it_behaves_like 'includes Limitable concern' do
subject { build(:ci_trigger, owner: project.owner, project: project) }
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