summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-05-11 00:13:54 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-05-11 00:13:54 +0000
commit2d9c62ffb595d2bf555046d09098a0d4af71e17f (patch)
treec837cf91cf3e50f443d1dcb852b82448637a5c8b /lib
parentd9710d79c52bc73438022e79c79cfe3ab35b084b (diff)
downloadgitlab-ce-2d9c62ffb595d2bf555046d09098a0d4af71e17f.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/api/helpers/members_helpers.rb3
-rw-r--r--lib/gitlab/ci/build/rules.rb11
-rw-r--r--lib/gitlab/ci/config/entry/rules/rule.rb10
-rw-r--r--lib/gitlab/ci/yaml_processor.rb12
-rw-r--r--lib/gitlab/database/partitioning/list/convert_table.rb6
5 files changed, 30 insertions, 12 deletions
diff --git a/lib/api/helpers/members_helpers.rb b/lib/api/helpers/members_helpers.rb
index 90f86688367..b3c79486465 100644
--- a/lib/api/helpers/members_helpers.rb
+++ b/lib/api/helpers/members_helpers.rb
@@ -55,7 +55,8 @@ module API
end
def find_all_members_for_project(project)
- MembersFinder.new(project, current_user).execute(include_relations: [:inherited, :direct, :invited_groups])
+ include_relations = [:inherited, :direct, :invited_groups, :shared_into_ancestors]
+ MembersFinder.new(project, current_user).execute(include_relations: include_relations)
end
def find_all_members_for_group(group)
diff --git a/lib/gitlab/ci/build/rules.rb b/lib/gitlab/ci/build/rules.rb
index dee95534b07..bc7aad1b186 100644
--- a/lib/gitlab/ci/build/rules.rb
+++ b/lib/gitlab/ci/build/rules.rb
@@ -6,12 +6,14 @@ module Gitlab
class Rules
include ::Gitlab::Utils::StrongMemoize
- Result = Struct.new(:when, :start_in, :allow_failure, :variables, :errors) do
+ Result = Struct.new(:when, :start_in, :allow_failure, :variables, :needs, :errors) do
def build_attributes
{
when: self.when,
options: { start_in: start_in }.compact,
- allow_failure: allow_failure
+ allow_failure: allow_failure,
+ scheduling_type: (:dag if needs),
+ needs_attributes: needs&.[](:job)
}.compact
end
@@ -33,13 +35,14 @@ module Gitlab
matched_rule.attributes[:when] || @default_when,
matched_rule.attributes[:start_in],
matched_rule.attributes[:allow_failure],
- matched_rule.attributes[:variables]
+ matched_rule.attributes[:variables],
+ (matched_rule.attributes[:needs] if Feature.enabled?(:introduce_rules_with_needs, pipeline.project))
)
else
Result.new('never')
end
rescue Rule::Clause::ParseError => e
- Result.new('never', nil, nil, nil, [e.message])
+ Result.new('never', nil, nil, nil, nil, [e.message])
end
private
diff --git a/lib/gitlab/ci/config/entry/rules/rule.rb b/lib/gitlab/ci/config/entry/rules/rule.rb
index 63bf1b38ac6..1e7f6056a65 100644
--- a/lib/gitlab/ci/config/entry/rules/rule.rb
+++ b/lib/gitlab/ci/config/entry/rules/rule.rb
@@ -9,7 +9,7 @@ module Gitlab
include ::Gitlab::Config::Entry::Configurable
include ::Gitlab::Config::Entry::Attributable
- ALLOWED_KEYS = %i[if changes exists when start_in allow_failure variables].freeze
+ ALLOWED_KEYS = %i[if changes exists when start_in allow_failure variables needs].freeze
ALLOWED_WHEN = %w[on_success on_failure always never manual delayed].freeze
attributes :if, :exists, :when, :start_in, :allow_failure
@@ -20,6 +20,11 @@ module Gitlab
entry :variables, Entry::Variables,
description: 'Environment variables to define for rule conditions.'
+ entry :needs, Entry::Needs,
+ description: 'Needs configuration to define for rule conditions.',
+ metadata: { allowed_needs: %i[job] },
+ inherit: false
+
validations do
validates :config, presence: true
validates :config, type: { with: Hash }
@@ -46,7 +51,8 @@ module Gitlab
def value
config.merge(
changes: (changes_value if changes_defined?),
- variables: (variables_value if variables_defined?)
+ variables: (variables_value if variables_defined?),
+ needs: (needs_value if needs_defined?)
).compact
end
diff --git a/lib/gitlab/ci/yaml_processor.rb b/lib/gitlab/ci/yaml_processor.rb
index 63242d60c85..c69d9218a66 100644
--- a/lib/gitlab/ci/yaml_processor.rb
+++ b/lib/gitlab/ci/yaml_processor.rb
@@ -94,16 +94,20 @@ module Gitlab
end
def validate_job_needs!(name, job)
- return unless needs = job.dig(:needs, :job)
+ validate_needs_specification!(name, job.dig(:needs, :job))
- validate_duplicate_needs!(name, needs)
+ job[:rules]&.each do |rule|
+ validate_needs_specification!(name, rule.dig(:needs, :job))
+ end
+ end
+
+ def validate_needs_specification!(name, needs)
+ return unless needs
needs.each do |need|
validate_job_dependency!(name, need[:name], 'need', optional: need[:optional])
end
- end
- def validate_duplicate_needs!(name, needs)
duplicated_needs =
needs
.group_by { |need| need[:name] }
diff --git a/lib/gitlab/database/partitioning/list/convert_table.rb b/lib/gitlab/database/partitioning/list/convert_table.rb
index d40ddc7a4d8..d4fb150d956 100644
--- a/lib/gitlab/database/partitioning/list/convert_table.rb
+++ b/lib/gitlab/database/partitioning/list/convert_table.rb
@@ -43,8 +43,13 @@ module Gitlab
create_parent_table
attach_foreign_keys_to_parent
+ locking_sql = locking_configuration.locking_statement_for(tables_that_will_lock_during_partitioning)
locking_configuration.with_lock_retries do
+ # Loose FKs trigger will exclusively lock the table and it might
+ # not follow the locking order needed to attach the partition.
+ migration_context.execute(locking_sql) if locking_sql.present?
+
redefine_loose_foreign_key_triggers do
migration_context.execute(sql_to_convert_table)
end
@@ -85,7 +90,6 @@ module Gitlab
# but they acquire the same locks so it's much faster to include them
# here.
[
- locking_configuration.locking_statement_for(tables_that_will_lock_during_partitioning),
attach_table_to_parent_statement,
alter_sequence_statements(old_table: table_name, new_table: parent_table_name),
remove_constraint_statement