Remove fallback to project.deployment_platform
This improves query performance of MergeRequestsController#ci_environments_status a lot. However this means old deployments that deployed to kubernetes clusters with prometheus installations will no longer show performance metrics as we cannot backfill cluster_id from deployment_platform with certainty (clusters may be edited/added/deleted, which changes the results of deployment_platform).
This commit is contained in:
parent
72339077f7
commit
1668f40f43
|
@ -206,13 +206,8 @@ class Deployment < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
# TODO remove fallback case to deployment_platform_cluster.
|
||||
# Otherwise we will continue to pay the performance penalty described in
|
||||
# https://gitlab.com/gitlab-org/gitlab-ce/issues/63475
|
||||
def cluster_prometheus
|
||||
cluster_with_fallback = cluster || deployment_platform_cluster
|
||||
|
||||
cluster_with_fallback.application_prometheus if cluster_with_fallback&.application_prometheus_available?
|
||||
cluster.application_prometheus if cluster&.application_prometheus_available?
|
||||
end
|
||||
|
||||
def ref_path
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
title: Improve performance of MergeRequestsController#ci_environment_status endpoint
|
||||
merge_request: 30224
|
||||
author:
|
||||
type: performance
|
|
@ -341,18 +341,6 @@ describe Deployment do
|
|||
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
|
||||
context 'fallback deployment platform' do
|
||||
let(:cluster) { create(:cluster, :provided_by_user, environment_scope: '*', projects: [deployment.project]) }
|
||||
let!(:prometheus) { create(:clusters_applications_prometheus, :installed, cluster: cluster) }
|
||||
|
||||
before do
|
||||
expect(deployment.project).to receive(:deployment_platform).and_return(cluster.platform)
|
||||
expect(cluster.application_prometheus).to receive(:can_query?).and_return(true)
|
||||
end
|
||||
|
||||
it { is_expected.to be_truthy }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue