diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-27 14:45:16 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-27 14:45:16 +0300 |
commit | f444f745544528accf5811bb9a8fb0a252775d3b (patch) | |
tree | c248e283ea2825b68f405e738faea0e56ed57bba /app | |
parent | 58fa510acd34ab3c8b36be95f5e7b58dd9b0f5f4 (diff) |
Add latest changes from gitlab-org/gitlab@12-6-stable-ee
Diffstat (limited to 'app')
-rw-r--r-- | app/finders/clusters/knative_serving_namespace_finder.rb | 8 | ||||
-rw-r--r-- | app/models/ci/pipeline.rb | 6 | ||||
-rw-r--r-- | app/serializers/pipeline_entity.rb | 2 | ||||
-rw-r--r-- | app/serializers/pipeline_serializer.rb | 5 |
4 files changed, 17 insertions, 4 deletions
diff --git a/app/finders/clusters/knative_serving_namespace_finder.rb b/app/finders/clusters/knative_serving_namespace_finder.rb index d3db5be558c..b6cf84beb79 100644 --- a/app/finders/clusters/knative_serving_namespace_finder.rb +++ b/app/finders/clusters/knative_serving_namespace_finder.rb @@ -12,6 +12,14 @@ module Clusters cluster.kubeclient&.get_namespace(Clusters::Kubernetes::KNATIVE_SERVING_NAMESPACE) rescue Kubeclient::ResourceNotFoundError nil + rescue Kubeclient::HttpError => e + # If the kubernetes auth engine is enabled, it will return 403 + if e.error_code == 403 + Gitlab::ErrorTracking.track_exception(e) + nil + else + raise + end end end end diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 29ec41ef1a1..3710a0b914e 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -32,6 +32,7 @@ module Ci has_many :stages, -> { order(position: :asc) }, inverse_of: :pipeline has_many :statuses, class_name: 'CommitStatus', foreign_key: :commit_id, inverse_of: :pipeline + has_many :latest_statuses_ordered_by_stage, -> { latest.order(:stage_idx, :stage) }, class_name: 'CommitStatus', foreign_key: :commit_id, inverse_of: :pipeline has_many :processables, -> { processables }, class_name: 'CommitStatus', foreign_key: :commit_id, inverse_of: :pipeline has_many :builds, foreign_key: :commit_id, inverse_of: :pipeline @@ -45,6 +46,7 @@ module Ci has_many :merge_requests_as_head_pipeline, foreign_key: "head_pipeline_id", class_name: 'MergeRequest' has_many :pending_builds, -> { pending }, foreign_key: :commit_id, class_name: 'Ci::Build' + has_many :failed_builds, -> { latest.failed }, foreign_key: :commit_id, class_name: 'Ci::Build', inverse_of: :pipeline has_many :retryable_builds, -> { latest.failed_or_canceled.includes(:project) }, foreign_key: :commit_id, class_name: 'Ci::Build' has_many :cancelable_statuses, -> { cancelable }, foreign_key: :commit_id, class_name: 'CommitStatus' has_many :manual_actions, -> { latest.manual_actions.includes(:project) }, foreign_key: :commit_id, class_name: 'Ci::Build' @@ -377,9 +379,7 @@ module Ci end def legacy_stages_using_composite_status - stages = statuses.latest - .order(:stage_idx, :stage) - .group_by(&:stage) + stages = latest_statuses_ordered_by_stage.group_by(&:stage) stages.map do |stage_name, jobs| composite_status = Gitlab::Ci::Status::Composite diff --git a/app/serializers/pipeline_entity.rb b/app/serializers/pipeline_entity.rb index cddb894fd64..6b2a1bfe666 100644 --- a/app/serializers/pipeline_entity.rb +++ b/app/serializers/pipeline_entity.rb @@ -78,7 +78,7 @@ class PipelineEntity < Grape::Entity end expose :failed_builds, if: -> (*) { can_retry? }, using: JobEntity do |pipeline| - pipeline.builds.failed + pipeline.failed_builds end private diff --git a/app/serializers/pipeline_serializer.rb b/app/serializers/pipeline_serializer.rb index fc3160e3c69..b25a1ea9209 100644 --- a/app/serializers/pipeline_serializer.rb +++ b/app/serializers/pipeline_serializer.rb @@ -40,7 +40,11 @@ class PipelineSerializer < BaseSerializer def preloaded_relations [ + :latest_statuses_ordered_by_stage, :stages, + { + failed_builds: %i(project metadata) + }, :retryable_builds, :cancelable_statuses, :trigger_requests, @@ -48,6 +52,7 @@ class PipelineSerializer < BaseSerializer :scheduled_actions, :artifacts, :merge_request, + :user, { pending_builds: :project, project: [:route, { namespace: :route }], |