summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThong Kuah <tkuah@gitlab.com>2019-07-01 20:24:20 +1200
committerThong Kuah <tkuah@gitlab.com>2019-07-08 09:13:21 +1200
commit1668f40f430c656ed9c20898605db21a66cb5937 (patch)
treed26ae7edb98df825116cd767dd1f85f2c5a452a6
parent72339077f7d79eeb9d0612c55236aa4aa6da4084 (diff)
downloadgitlab-ce-1668f40f430c656ed9c20898605db21a66cb5937.tar.gz
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).
-rw-r--r--app/models/deployment.rb7
-rw-r--r--changelogs/unreleased/63475-fix-n-1.yml5
-rw-r--r--spec/models/deployment_spec.rb12
3 files changed, 6 insertions, 18 deletions
diff --git a/app/models/deployment.rb b/app/models/deployment.rb
index a8f5642f726..3b31e7b1333 100644
--- a/app/models/deployment.rb
+++ b/app/models/deployment.rb
@@ -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
diff --git a/changelogs/unreleased/63475-fix-n-1.yml b/changelogs/unreleased/63475-fix-n-1.yml
new file mode 100644
index 00000000000..3ed825290fd
--- /dev/null
+++ b/changelogs/unreleased/63475-fix-n-1.yml
@@ -0,0 +1,5 @@
+---
+title: Improve performance of MergeRequestsController#ci_environment_status endpoint
+merge_request: 30224
+author:
+type: performance
diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb
index 713fb647708..a926e1913a7 100644
--- a/spec/models/deployment_spec.rb
+++ b/spec/models/deployment_spec.rb
@@ -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