diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb
index 0de619793473a42be09ae51bd6e3bd6708488233..57fbe48297011b606eb131ab0c5f388151cabd19 100644
--- a/app/models/ci/runner.rb
+++ b/app/models/ci/runner.rb
@@ -67,7 +67,7 @@ class Runner < Ci::ApplicationRecord
UPDATE_CONTACT_COLUMN_EVERY = ((40.minutes)..(55.minutes))
# The `STALE_TIMEOUT` constant defines the how far past the last contact or creation date a runner will be considered stale
- STALE_TIMEOUT = 3.months
+ STALE_TIMEOUT = 7.days
# Only allow authentication token to be visible for a short while
REGISTRATION_AVAILABILITY_TIME = 1.hour
diff --git a/doc/administration/instance_limits.md b/doc/administration/instance_limits.md
index 8e7993f5cae08787fc9d6d54c87e1097087e6969..99712755bc224253ce38a7cd6ea975a5ef6151a0 100644
--- a/doc/administration/instance_limits.md
+++ b/doc/administration/instance_limits.md
@@ -674,8 +674,10 @@ of extra Pages deployments permitted for a top-level namespace is 1000.
### Number of registered runners per scope
+> - Runner stale timeout [changed](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/155795) from 3 months to 7 days in GitLab 17.1.
+
The total number of registered runners is limited at the group and project levels. Each time a new runner is registered,
-GitLab checks these limits against runners that have been active in the last 3 months.
+GitLab checks these limits against runners that have been active in the last 7 days.
A runner's registration fails if it exceeds the limit for the scope determined by the runner registration token.
If the limit value is set to zero, the limit is disabled.
diff --git a/doc/api/graphql/reference/index.md b/doc/api/graphql/reference/index.md
index 80b4201a56bdf5ae9ae5b6ae779f1d8a73b00a9c..35f2cc66f4e892a6f21c7a22f8bddb965197d49e 100644
--- a/doc/api/graphql/reference/index.md
+++ b/doc/api/graphql/reference/index.md
@@ -33298,10 +33298,10 @@ Values for sorting runners.
| ----- | ----------- |
| `ACTIVE` **{warning-solid}** | **Deprecated** in GitLab 14.6. This was renamed. Use: [`CiRunner.paused`](#cirunnerpaused). |
| `NEVER_CONTACTED` | Runner that has never contacted this instance. |
-| `OFFLINE` | Runner that has not contacted this instance within the last 2 hours. Will be considered `STALE` if offline for more than 3 months. |
+| `OFFLINE` | Runner that has not contacted this instance within the last 2 hours. Will be considered `STALE` if offline for more than 7 days. |
| `ONLINE` | Runner that contacted this instance within the last 2 hours. |
| `PAUSED` **{warning-solid}** | **Deprecated** in GitLab 14.6. This was renamed. Use: [`CiRunner.paused`](#cirunnerpaused). |
-| `STALE` | Runner that has not contacted this instance within the last 3 months. |
+| `STALE` | Runner that has not contacted this instance within the last 7 days. |
### `CiRunnerType`
diff --git a/doc/ci/runners/runners_scope.md b/doc/ci/runners/runners_scope.md
index a853c9978ef97d5ca4daa2e21d1aea06a981c6e1..78b72d63a2e476d210b8ecf49873a3bb0b21f550 100644
--- a/doc/ci/runners/runners_scope.md
+++ b/doc/ci/runners/runners_scope.md
@@ -584,7 +584,7 @@ A runner can have one of the following statuses.
|---------|-------------|
| `online` | The runner has contacted GitLab within the last 2 hours and is available to run jobs. |
| `offline` | The runner has not contacted GitLab in more than 2 hours and is not available to run jobs. Check the runner to see if you can bring it online. |
-| `stale` | The runner has not contacted GitLab in more than 3 months. If the runner was created more than 3 months ago, but it never contacted the instance, it is also considered **stale**. |
+| `stale` | The runner has not contacted GitLab in more than 7 days. If the runner was created more than 7 days ago, but it never contacted the instance, it is also considered **stale**. |
| `never_contacted` | The runner has never contacted GitLab. To make the runner contact GitLab, run `gitlab-runner run`. |
## View statistics for runner performance
diff --git a/ee/spec/services/ci/runners/stale_group_runners_prune_service_spec.rb b/ee/spec/services/ci/runners/stale_group_runners_prune_service_spec.rb
index 73585b7d598c67dd02edae7d6af4a240acc4e4b5..c92e8519b27737c8c00b247e1512d6f32425ba38 100644
--- a/ee/spec/services/ci/runners/stale_group_runners_prune_service_spec.rb
+++ b/ee/spec/services/ci/runners/stale_group_runners_prune_service_spec.rb
@@ -13,7 +13,7 @@
end
let!(:stale_runners) do
- create_list(:ci_runner, 3, :group, groups: [group1], created_at: 5.months.ago, contacted_at: 4.months.ago)
+ create_list(:ci_runner, 3, :group, groups: [group1], created_at: 5.months.ago, contacted_at: 8.days.ago)
end
let(:group2) { create(:group) }
diff --git a/spec/features/admin/admin_runners_spec.rb b/spec/features/admin/admin_runners_spec.rb
index 8eedd53e58f4250d02705399d3dca5b2cdfe6e5f..ce520adb1de7804896d9616a6eed73fa5f0191bb 100644
--- a/spec/features/admin/admin_runners_spec.rb
+++ b/spec/features/admin/admin_runners_spec.rb
@@ -62,8 +62,8 @@
context "with multiple runners" do
before do
create(:ci_runner, :instance, created_at: 1.year.ago, contacted_at: Time.zone.now)
+ create(:ci_runner, :instance, created_at: 1.year.ago, contacted_at: 1.day.ago)
create(:ci_runner, :instance, created_at: 1.year.ago, contacted_at: 1.week.ago)
- create(:ci_runner, :instance, created_at: 1.year.ago, contacted_at: 1.year.ago)
visit admin_runners_path
end
diff --git a/spec/helpers/ci/runners_helper_spec.rb b/spec/helpers/ci/runners_helper_spec.rb
index 9252f765579fb9e7b58b78ea281143907540b9f0..3f928667dad97556b0f58db47162f617c5d85e21 100644
--- a/spec/helpers/ci/runners_helper_spec.rb
+++ b/spec/helpers/ci/runners_helper_spec.rb
@@ -147,7 +147,7 @@
group_full_path: group.full_path,
runner_install_help_page: 'https://docs.gitlab.com/runner/install/',
online_contact_timeout_secs: 7200,
- stale_timeout_secs: 7889238
+ stale_timeout_secs: 604800
)
end
end
diff --git a/spec/models/ci/runner_spec.rb b/spec/models/ci/runner_spec.rb
index eb440dd7ddf02e1d6b58fa6e60c650476ad70ff5..e1b47c6b17d347cdce0ca901eb69cf067fb15dd2 100644
--- a/spec/models/ci/runner_spec.rb
+++ b/spec/models/ci/runner_spec.rb
@@ -474,10 +474,10 @@
describe '.recent' do
subject { described_class.recent }
- let!(:runner1) { create(:ci_runner, :instance, contacted_at: nil, created_at: 2.months.ago) }
- let!(:runner2) { create(:ci_runner, :instance, contacted_at: nil, created_at: 3.months.ago) }
- let!(:runner3) { create(:ci_runner, :instance, contacted_at: 1.month.ago, created_at: 2.months.ago) }
- let!(:runner4) { create(:ci_runner, :instance, contacted_at: 1.month.ago, created_at: 3.months.ago) }
+ let!(:runner1) { create(:ci_runner, contacted_at: nil, created_at: 6.days.ago) }
+ let!(:runner2) { create(:ci_runner, contacted_at: nil, created_at: 7.days.ago) }
+ let!(:runner3) { create(:ci_runner, contacted_at: 1.day.ago, created_at: 6.days.ago) }
+ let!(:runner4) { create(:ci_runner, contacted_at: 1.day.ago, created_at: 7.days.ago) }
it { is_expected.to contain_exactly(runner1, runner3, runner4) }
end
@@ -569,11 +569,11 @@
using RSpec::Parameterized::TableSyntax
where(:created_at, :contacted_at, :expected_stale?) do
- nil | nil | false
- 3.months.ago | 3.months.ago | true
- 3.months.ago | (3.months - 1.hour).ago | false
- 3.months.ago | nil | true
- (3.months - 1.hour).ago | nil | false
+ nil | nil | false
+ 7.days.ago | 7.days.ago | true
+ 7.days.ago | (7.days - 1.hour).ago | false
+ 7.days.ago | nil | true
+ (7.days - 1.hour).ago | nil | false
end
with_them do
@@ -866,7 +866,7 @@ def stub_redis_runner_contacted_at(value)
subject { runner.status }
context 'never connected' do
- let(:runner) { build(:ci_runner, :instance, :unregistered, created_at: 3.months.ago) }
+ let(:runner) { build(:ci_runner, :instance, :unregistered, created_at: 7.days.ago) }
it { is_expected.to eq(:stale) }
@@ -890,13 +890,13 @@ def stub_redis_runner_contacted_at(value)
end
context 'contacted recently' do
- let(:runner) { build(:ci_runner, :instance, contacted_at: (3.months - 1.second).ago) }
+ let(:runner) { build(:ci_runner, :instance, contacted_at: (7.days - 1.second).ago) }
it { is_expected.to eq(:offline) }
end
context 'contacted long time ago' do
- let(:runner) { build(:ci_runner, :instance, created_at: 3.months.ago, contacted_at: 3.months.ago) }
+ let(:runner) { build(:ci_runner, :instance, created_at: 7.days.ago, contacted_at: 7.days.ago) }
it { is_expected.to eq(:stale) }
end
@@ -925,8 +925,8 @@ def stub_redis_runner_contacted_at(value)
context 'contacted long time ago' do
before do
- runner.created_at = 3.months.ago
- runner.contacted_at = 3.months.ago
+ runner.created_at = 7.days.ago
+ runner.contacted_at = 7.days.ago
end
it { is_expected.to eq(:stale) }
@@ -2042,7 +2042,7 @@ def does_db_update
describe '.stale_deadline', :freeze_time do
subject { described_class.stale_deadline }
- it { is_expected.to eq(3.months.ago) }
+ it { is_expected.to eq(7.days.ago) }
end
describe '.with_runner_type' do
diff --git a/spec/requests/api/graphql/ci/runner_spec.rb b/spec/requests/api/graphql/ci/runner_spec.rb
index fc5aa59b731cfd2aaf1a41b814a5e1ad09ac3dac..437a56b3cd3380b1b6afa408758b8fbe01c3fec9 100644
--- a/spec/requests/api/graphql/ci/runner_spec.rb
+++ b/spec/requests/api/graphql/ci/runner_spec.rb
@@ -689,7 +689,7 @@
end
let_it_be(:never_contacted_instance_runner) do
- create(:ci_runner, :unregistered, description: 'Missing runner 1', created_at: 1.month.ago)
+ create(:ci_runner, :unregistered, description: 'Missing runner 1', created_at: 6.days.ago)
end
let(:query) do
diff --git a/spec/services/ci/runners/register_runner_service_spec.rb b/spec/services/ci/runners/register_runner_service_spec.rb
index 7c7c27a3d19fa358f6def0aafdf5c7b6cc746c74..1dc6e760c088f3e5a6c94968c637b8f86ce13428 100644
--- a/spec/services/ci/runners/register_runner_service_spec.rb
+++ b/spec/services/ci/runners/register_runner_service_spec.rb
@@ -246,7 +246,7 @@
context 'when it exceeds the application limits' do
before do
- create(:ci_runner, :unregistered, runner_type: :group_type, groups: [group], created_at: 1.month.ago)
+ create(:ci_runner, :unregistered, runner_type: :group_type, groups: [group], created_at: 6.days.ago)
create(:plan_limits, :default_plan, ci_registered_group_runners: 1)
end
diff --git a/spec/support/shared_examples/helpers/runners_shared_examples.rb b/spec/support/shared_examples/helpers/runners_shared_examples.rb
index e509f7a65a558958fe6c92dd65054f1245dbc54f..01f38d13c06f9abed8b3242238ca351f29ba75aa 100644
--- a/spec/support/shared_examples/helpers/runners_shared_examples.rb
+++ b/spec/support/shared_examples/helpers/runners_shared_examples.rb
@@ -6,7 +6,7 @@
runner_install_help_page: 'https://docs.gitlab.com/runner/install/',
registration_token: Gitlab::CurrentSettings.runners_registration_token,
online_contact_timeout_secs: 7200,
- stale_timeout_secs: 7889238
+ stale_timeout_secs: 604800
)
end
end