Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-09-20 14:18:08 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-09-20 14:18:08 +0300
commit5afcbe03ead9ada87621888a31a62652b10a7e4f (patch)
tree9918b67a0d0f0bafa6542e839a8be37adf73102d /app/models/ci
parentc97c0201564848c1f53226fe19d71fdcc472f7d0 (diff)
Add latest changes from gitlab-org/gitlab@16-4-stable-eev16.4.0-rc42
Diffstat (limited to 'app/models/ci')
-rw-r--r--app/models/ci/build.rb24
-rw-r--r--app/models/ci/build_need.rb5
-rw-r--r--app/models/ci/build_runner_session.rb2
-rw-r--r--app/models/ci/pipeline.rb2
-rw-r--r--app/models/ci/runner.rb10
5 files changed, 27 insertions, 16 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 7a623b0cefb..2abb8e4be48 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -165,7 +165,10 @@ module Ci
scope :with_live_trace, -> { where('EXISTS (?)', Ci::BuildTraceChunk.where("#{quoted_table_name}.id = #{Ci::BuildTraceChunk.quoted_table_name}.build_id").select(1)) }
scope :with_stale_live_trace, -> { with_live_trace.finished_before(12.hours.ago) }
scope :finished_before, -> (date) { finished.where('finished_at < ?', date) }
- scope :license_management_jobs, -> { where(name: %i(license_management license_scanning)) } # handle license rename https://gitlab.com/gitlab-org/gitlab/issues/8911
+ scope :license_management_jobs, -> { where(name: %i[license_management license_scanning]) } # handle license rename https://gitlab.com/gitlab-org/gitlab/issues/8911
+ # WARNING: This scope could lead to performance implications for large size of tables `ci_builds` and ci_runners`.
+ # See https://gitlab.com/gitlab-org/gitlab/-/merge_requests/123131
+ scope :with_runner_type, -> (runner_type) { joins(:runner).where(runner: { runner_type: runner_type }) }
scope :with_secure_reports_from_config_options, -> (job_types) do
joins(:metadata).where("#{Ci::BuildMetadata.quoted_table_name}.config_options -> 'artifacts' -> 'reports' ?| array[:job_types]", job_types: job_types)
@@ -388,6 +391,9 @@ module Ci
name == 'pages'
end
+ # overridden on EE
+ def pages_path_prefix; end
+
def runnable?
true
end
@@ -408,7 +414,7 @@ module Ci
end
def options_scheduled_at
- ChronicDuration.parse(options[:start_in])&.seconds&.from_now
+ ChronicDuration.parse(options[:start_in], use_complete_matcher: true)&.seconds&.from_now
end
def action?
@@ -487,10 +493,7 @@ module Ci
Gitlab::Ci::Variables::Collection.new.tap do |variables|
break variables unless persisted? && persisted_environment.present?
- variables.concat(persisted_environment.predefined_variables)
-
- variables.append(key: 'CI_ENVIRONMENT_ACTION', value: environment_action)
- variables.append(key: 'CI_ENVIRONMENT_TIER', value: environment_tier)
+ variables.append(key: 'CI_ENVIRONMENT_SLUG', value: environment_slug)
# Here we're passing unexpanded environment_url for runner to expand,
# and we need to make sure that CI_ENVIRONMENT_NAME and
@@ -735,7 +738,7 @@ module Ci
def artifacts_expire_in=(value)
self.artifacts_expire_at =
if value
- ChronicDuration.parse(value)&.seconds&.from_now
+ ChronicDuration.parse(value, use_complete_matcher: true)&.seconds&.from_now
end
end
@@ -1039,6 +1042,13 @@ module Ci
end
end
+ def time_in_queue_seconds
+ return if queued_at.nil?
+
+ (::Time.current - queued_at).seconds.to_i
+ end
+ strong_memoize_attr :time_in_queue_seconds
+
protected
def run_status_commit_hooks!
diff --git a/app/models/ci/build_need.rb b/app/models/ci/build_need.rb
index 317f2523f69..00241908644 100644
--- a/app/models/ci/build_need.rb
+++ b/app/models/ci/build_need.rb
@@ -7,15 +7,16 @@ module Ci
include SafelyChangeColumnDefault
include BulkInsertSafe
+ MAX_JOB_NAME_LENGTH = 128
+
columns_changing_default :partition_id
- ignore_column :id_convert_to_bigint, remove_with: '16.4', remove_after: '2023-09-22'
belongs_to :build, class_name: "Ci::Processable", foreign_key: :build_id, inverse_of: :needs
partitionable scope: :build
validates :build, presence: true
- validates :name, presence: true, length: { maximum: 128 }
+ validates :name, presence: true, length: { maximum: MAX_JOB_NAME_LENGTH }
validates :optional, inclusion: { in: [true, false] }
scope :scoped_build, -> { where("#{Ci::Build.quoted_table_name}.id = #{quoted_table_name}.build_id") }
diff --git a/app/models/ci/build_runner_session.rb b/app/models/ci/build_runner_session.rb
index eaa2e1c428e..e197217bb70 100644
--- a/app/models/ci/build_runner_session.rb
+++ b/app/models/ci/build_runner_session.rb
@@ -20,7 +20,7 @@ module Ci
partitionable scope: :build
validates :build, presence: true
- validates :url, public_url: { schemes: %w(https) }
+ validates :url, public_url: { schemes: %w[https] }
def terminal_specification
wss_url = Gitlab::UrlHelpers.as_wss(Addressable::URI.escape(url))
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index 3a5db04a687..5bf4e846304 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -162,7 +162,7 @@ module Ci
validates :status, presence: { unless: :importing? }
validate :valid_commit_sha, unless: :importing?
- validates :source, exclusion: { in: %w(unknown), unless: :importing? }, on: :create
+ validates :source, exclusion: { in: %w[unknown], unless: :importing? }, on: :create
after_create :keep_around_commits, unless: :importing?
after_find :observe_age_in_minutes, unless: :importing?
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb
index 8d93429fd24..91c919dc662 100644
--- a/app/models/ci/runner.rb
+++ b/app/models/ci/runner.rb
@@ -52,7 +52,7 @@ module Ci
RUNNER_QUEUE_EXPIRY_TIME = 1.hour
# The `UPDATE_CONTACT_COLUMN_EVERY` defines how often the Runner DB entry can be updated
- UPDATE_CONTACT_COLUMN_EVERY = (40.minutes..55.minutes).freeze
+ 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
@@ -532,7 +532,9 @@ module Ci
'virtualbox' => :virtualbox,
'docker+machine' => :docker_machine,
'docker-ssh+machine' => :docker_ssh_machine,
- 'kubernetes' => :kubernetes
+ 'kubernetes' => :kubernetes,
+ 'docker-autoscaler' => :docker_autoscaler,
+ 'instance' => :instance
}.freeze
EXECUTOR_TYPE_TO_NAMES = EXECUTOR_NAME_TO_TYPES.invert.freeze
@@ -552,9 +554,7 @@ module Ci
end
def cleanup_runner_queue
- Gitlab::Redis::SharedState.with do |redis|
- redis.del(runner_queue_key)
- end
+ ::Gitlab::Workhorse.cleanup_key(runner_queue_key)
end
def runner_queue_key