From 67dba08fc03c2340ebc658b4d1838d290f1afb2f Mon Sep 17 00:00:00 2001
From: Ben Bodenmiller <5332-bbodenmiller@users.noreply.gitlab.com>
Date: Wed, 3 Feb 2021 02:29:11 +0000
Subject: [PATCH] Run pipeline_schedule_worker at every 10th minute from 3
 through 59

---
 .../52756-pipeline_schedule_worker_cron.yml           |  5 +++++
 config/gitlab.yml.example                             |  2 +-
 config/initializers/1_settings.rb                     |  2 +-
 doc/user/gitlab_com/index.md                          |  2 +-
 spec/lib/gitlab/ci/cron_parser_spec.rb                | 11 +++++++++++
 5 files changed, 19 insertions(+), 3 deletions(-)
 create mode 100644 changelogs/unreleased/52756-pipeline_schedule_worker_cron.yml

diff --git a/changelogs/unreleased/52756-pipeline_schedule_worker_cron.yml b/changelogs/unreleased/52756-pipeline_schedule_worker_cron.yml
new file mode 100644
index 000000000000..ddcecb52d995
--- /dev/null
+++ b/changelogs/unreleased/52756-pipeline_schedule_worker_cron.yml
@@ -0,0 +1,5 @@
+---
+title: Run pipeline_schedule_worker at every 10th minute from 3 through 59
+merge_request: 52756
+author: Ben Bodenmiller (@bbodenmiller)
+type: changed
diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example
index a4609b26e0cd..6b6188a3fdf7 100644
--- a/config/gitlab.yml.example
+++ b/config/gitlab.yml.example
@@ -435,7 +435,7 @@ production: &base
       cron: "0 * * * *"
     # Execute scheduled triggers
     pipeline_schedule_worker:
-      cron: "19 * * * *"
+      cron: "3-59/10 * * * *"
     # Remove expired build artifacts
     expire_build_artifacts_worker:
       cron: "*/7 * * * *"
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index 6339624ab7e4..9b295c440db5 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -416,7 +416,7 @@
 Settings.cron_jobs['stuck_ci_jobs_worker']['cron'] ||= '0 * * * *'
 Settings.cron_jobs['stuck_ci_jobs_worker']['job_class'] = 'StuckCiJobsWorker'
 Settings.cron_jobs['pipeline_schedule_worker'] ||= Settingslogic.new({})
-Settings.cron_jobs['pipeline_schedule_worker']['cron'] ||= '19 * * * *'
+Settings.cron_jobs['pipeline_schedule_worker']['cron'] ||= '3-59/10 * * * *'
 Settings.cron_jobs['pipeline_schedule_worker']['job_class'] = 'PipelineScheduleWorker'
 Settings.cron_jobs['expire_build_artifacts_worker'] ||= Settingslogic.new({})
 Settings.cron_jobs['expire_build_artifacts_worker']['cron'] ||= '*/7 * * * *'
diff --git a/doc/user/gitlab_com/index.md b/doc/user/gitlab_com/index.md
index 9bae089b9d66..d474392b52a9 100644
--- a/doc/user/gitlab_com/index.md
+++ b/doc/user/gitlab_com/index.md
@@ -97,7 +97,7 @@ Any settings or feature limits not listed here are using the defaults listed in
 | -----------             | ----------------- | ------------- |
 | Artifacts maximum size (compressed) | 1G                | 100M          |
 | Artifacts [expiry time](../../ci/yaml/README.md#artifactsexpire_in)   | From June 22, 2020, deleted after 30 days unless otherwise specified (artifacts created before that date have no expiry).           | deleted after 30 days unless otherwise specified    |
-| Scheduled Pipeline Cron | `*/5 * * * *` | `19 * * * *` |
+| 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 pipeline schedules in projects](../../administration/instance_limits.md#number-of-pipeline-schedules) | `10` for Free tier, `50` for all paid tiers | Unlimited |
diff --git a/spec/lib/gitlab/ci/cron_parser_spec.rb b/spec/lib/gitlab/ci/cron_parser_spec.rb
index dd27b4045c9a..15293429354c 100644
--- a/spec/lib/gitlab/ci/cron_parser_spec.rb
+++ b/spec/lib/gitlab/ci/cron_parser_spec.rb
@@ -63,6 +63,17 @@
       end
     end
 
+    context 'when range and slash used' do
+      let(:cron) { '3-59/10 * * * *' }
+      let(:cron_timezone) { 'UTC' }
+
+      it_behaves_like returns_time_for_epoch
+
+      it 'returns specific time' do
+        expect(subject.min).to be_in([3, 13, 23, 33, 43, 53])
+      end
+    end
+
     context 'when cron_timezone is TZInfo format' do
       before do
         allow(Time).to receive(:zone)
-- 
GitLab