summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessio Caiazza <nolith@abisso.org>2017-05-27 17:14:34 +0200
committerAlessio Caiazza <nolith@abisso.org>2017-07-07 09:25:45 +0200
commiteec8a0b1f585fb693547cbfd2bc492e5abb8a2f9 (patch)
tree4a976725d71088232270868e08c8c833fb1c83c8
parent6c15905c3bd11209858eac8870ffa9211f08f157 (diff)
downloadgitlab-ce-eec8a0b1f585fb693547cbfd2bc492e5abb8a2f9.tar.gz
Fix offline runner detection
-rw-r--r--app/models/ci/runner.rb10
-rw-r--r--changelogs/unreleased/fix-runner_online_check.yml4
2 files changed, 11 insertions, 3 deletions
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb
index d12f96f3d0b..c806a0585dc 100644
--- a/app/models/ci/runner.rb
+++ b/app/models/ci/runner.rb
@@ -3,7 +3,7 @@ module Ci
extend Ci::Model
RUNNER_QUEUE_EXPIRY_TIME = 60.minutes
- LAST_CONTACT_TIME = 1.hour.ago
+ ONLINE_CONTACT_TIMEOUT = 1.hour
AVAILABLE_SCOPES = %w[specific shared active paused online].freeze
FORM_EDITABLE = %i[description tag_list active run_untagged locked].freeze
@@ -19,7 +19,7 @@ module Ci
scope :shared, ->() { where(is_shared: true) }
scope :active, ->() { where(active: true) }
scope :paused, ->() { where(active: false) }
- scope :online, ->() { where('contacted_at > ?', LAST_CONTACT_TIME) }
+ scope :online, ->() { where('contacted_at > ?', contact_time_deadline) }
scope :ordered, ->() { order(id: :desc) }
scope :owned_or_shared, ->(project_id) do
@@ -59,6 +59,10 @@ module Ci
where(t[:token].matches(pattern).or(t[:description].matches(pattern)))
end
+ def self.contact_time_deadline
+ ONLINE_CONTACT_TIMEOUT.ago
+ end
+
def set_default_values
self.token = SecureRandom.hex(15) if self.token.blank?
end
@@ -80,7 +84,7 @@ module Ci
end
def online?
- contacted_at && contacted_at > LAST_CONTACT_TIME
+ contacted_at && contacted_at > self.class.contact_time_deadline
end
def status
diff --git a/changelogs/unreleased/fix-runner_online_check.yml b/changelogs/unreleased/fix-runner_online_check.yml
new file mode 100644
index 00000000000..bc0de979b4c
--- /dev/null
+++ b/changelogs/unreleased/fix-runner_online_check.yml
@@ -0,0 +1,4 @@
+---
+title: Fix offline runner detection
+merge_request: 11751
+author: Alessio Caiazza