Commit 1668f40f authored by Thong Kuah's avatar Thong Kuah

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).
parent 72339077
......@@ -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
......
---
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment