Commit 392e50ff authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'mc/feature/limit-pipeline-schedules' into 'master'

Add application limits for Ci::PipelineSchedule

Closes #29566

See merge request gitlab-org/gitlab!27004
parents eb33a847 feb487b0
# frozen_string_literal: true
class AddCiPipelineSchedulesToPlanLimits < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
DOWNTIME = false
def up
add_column_with_default(:plan_limits, :ci_pipeline_schedules, :integer, default: 0, allow_null: false)
end
def down
remove_column(:plan_limits, :ci_pipeline_schedules)
end
end
# frozen_string_literal: true
class InsertCiPipelineSchedulesPlanLimits < ActiveRecord::Migration[6.0]
DOWNTIME = false
def change
return unless Gitlab.com?
create_or_update_plan_limit('ci_pipeline_schedules', 'free', 10)
create_or_update_plan_limit('ci_pipeline_schedules', 'bronze', 50)
create_or_update_plan_limit('ci_pipeline_schedules', 'silver', 50)
create_or_update_plan_limit('ci_pipeline_schedules', 'gold', 50)
end
def down
return unless Gitlab.com?
create_or_update_plan_limit('ci_pipeline_schedules', 'free', 0)
create_or_update_plan_limit('ci_pipeline_schedules', 'bronze', 0)
create_or_update_plan_limit('ci_pipeline_schedules', 'silver', 0)
create_or_update_plan_limit('ci_pipeline_schedules', 'gold', 0)
end
end
......@@ -3148,6 +3148,7 @@ ActiveRecord::Schema.define(version: 2020_03_12_163407) do
t.integer "project_hooks", default: 0, null: false
t.integer "group_hooks", default: 0, null: false
t.integer "ci_project_subscriptions", default: 0, null: false
t.integer "ci_pipeline_schedules", default: 0, null: false
t.index ["plan_id"], name: "index_plan_limits_on_plan_id", unique: true
end
......
......@@ -109,6 +109,29 @@ Plan.default.limits.update!(ci_project_subscriptions: 500)
NOTE: **Note:** Set the limit to `0` to disable it.
### Number of pipeline schedules
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/29566) in GitLab 12.10.
The total number of pipeline schedules can be limited per project. This limit is
checked each time a new pipeline schedule is created. If a new pipeline schedule
would cause the total number of pipeline schedules to exceed the limit, the
pipeline schedule will not be created.
On GitLab.com, different limits are [defined per plan](../user/gitlab_com/index.md#gitlab-cicd),
and they affect all projects under that plan.
On self-managed instances ([GitLab Starter](https://about.gitlab.com/pricing/#self-managed)
or higher tiers), this limit is defined for the `default` plan that affects all
projects. By default, there is no limit.
To set this limit on a self-managed installation, run the following in the
[GitLab Rails console](https://docs.gitlab.com/omnibus/maintenance/#starting-a-rails-console-session):
```ruby
Plan.default.limits.update!(ci_pipeline_schedules: 100)
```
## Environment data on Deploy Boards
[Deploy Boards](../user/project/deploy_boards.md) load information from Kubernetes about
......
......@@ -76,6 +76,7 @@ Below are the current settings regarding [GitLab CI/CD](../../ci/README.md).
| Artifacts [expiry time](../../ci/yaml/README.md#artifactsexpire_in) | kept forever | deleted after 30 days unless otherwise specified |
| Scheduled Pipeline Cron | `*/5 * * * *` | `19 * * * *` |
| [Max jobs in active pipelines](../../administration/instance_limits.md#number-of-jobs-in-active-pipelines) | `500` for Free tier, unlimited otherwise | Unlimited
| [Max pipeline schedules in projects](../../administration/instance_limits.md#number-of-pipeline-schedules) | `10` for Free tier, `50` for all paid tiers | Unlimited |
## Repository size limit
......
......@@ -5,7 +5,7 @@ module Ci
class Project < ApplicationRecord
include ::Limitable
self.table_name = "ci_subscriptions_projects"
self.table_name = 'ci_subscriptions_projects'
self.limit_name = 'ci_project_subscriptions'
self.limit_scope = :upstream_project
......
......@@ -7,6 +7,10 @@ module EE
prepended do
include UsageStatistics
include Limitable
self.limit_name = 'ci_pipeline_schedules'
self.limit_scope = :project
end
end
end
......
---
title: Add application limits for Ci::PipelineSchedule.
merge_request: 27004
author:
type: changed
# frozen_string_literal: true
require 'spec_helper'
describe Ci::PipelineSchedule do
it_behaves_like 'includes Limitable concern' do
subject { build(:ci_pipeline_schedule) }
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