diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 19:00:14 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 19:00:14 +0000 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /app/models/ci/runner_machine.rb | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) | |
download | gitlab-ce-05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2.tar.gz |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'app/models/ci/runner_machine.rb')
-rw-r--r-- | app/models/ci/runner_machine.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/app/models/ci/runner_machine.rb b/app/models/ci/runner_machine.rb new file mode 100644 index 00000000000..1dd997a8ee1 --- /dev/null +++ b/app/models/ci/runner_machine.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Ci + class RunnerMachine < Ci::ApplicationRecord + include FromUnion + include Ci::HasRunnerExecutor + + belongs_to :runner + + validates :runner, presence: true + validates :machine_xid, presence: true, length: { maximum: 64 } + validates :version, length: { maximum: 2048 } + validates :revision, length: { maximum: 255 } + validates :platform, length: { maximum: 255 } + validates :architecture, length: { maximum: 255 } + validates :ip_address, length: { maximum: 1024 } + validates :config, json_schema: { filename: 'ci_runner_config' } + + # The `STALE_TIMEOUT` constant defines the how far past the last contact or creation date a runner machine + # will be considered stale + STALE_TIMEOUT = 7.days + + scope :stale, -> do + created_some_time_ago = arel_table[:created_at].lteq(STALE_TIMEOUT.ago) + contacted_some_time_ago = arel_table[:contacted_at].lteq(STALE_TIMEOUT.ago) + + from_union( + where(contacted_at: nil), + where(contacted_some_time_ago), + remove_duplicates: false).where(created_some_time_ago) + end + end +end |