From 41f87e9e99e14f7d591f222b0246467acd040625 Mon Sep 17 00:00:00 2001 From: Thong Kuah Date: Thu, 25 Jul 2019 16:31:53 +1200 Subject: Removes potentially incorrect, and slow fallback Deployment_platform is relatively expensive and calling this after the fact means that this may not be the cluster that was deployed to. Correspondingly reduce the leeway given in the related N+1 spec --- app/models/deployment_metrics.rb | 13 +------------ ...move_deployment_metrics_deployment_platform_fallback.yml | 6 ++++++ spec/controllers/projects/merge_requests_controller_spec.rb | 5 ++--- spec/models/deployment_metrics_spec.rb | 12 ------------ 4 files changed, 9 insertions(+), 27 deletions(-) create mode 100644 changelogs/unreleased/remove_deployment_metrics_deployment_platform_fallback.yml diff --git a/app/models/deployment_metrics.rb b/app/models/deployment_metrics.rb index cfe762ca25e..2056c8bc59c 100644 --- a/app/models/deployment_metrics.rb +++ b/app/models/deployment_metrics.rb @@ -44,18 +44,7 @@ class DeploymentMetrics 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 - # - # Removal issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/64105 def cluster_prometheus - cluster_with_fallback = cluster || deployment_platform_cluster - - cluster_with_fallback.application_prometheus if cluster_with_fallback&.application_prometheus_available? - end - - def deployment_platform_cluster - deployment.environment.deployment_platform&.cluster + cluster.application_prometheus if cluster&.application_prometheus_available? end end diff --git a/changelogs/unreleased/remove_deployment_metrics_deployment_platform_fallback.yml b/changelogs/unreleased/remove_deployment_metrics_deployment_platform_fallback.yml new file mode 100644 index 00000000000..d32cbd1d8e0 --- /dev/null +++ b/changelogs/unreleased/remove_deployment_metrics_deployment_platform_fallback.yml @@ -0,0 +1,6 @@ +--- +title: Remove incorrect fallback when determining which cluster to use when retrieving + MR performance metrics +merge_request: 31126 +author: +type: changed diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb index f11880122b1..fa71d9b61b1 100644 --- a/spec/controllers/projects/merge_requests_controller_spec.rb +++ b/spec/controllers/projects/merge_requests_controller_spec.rb @@ -885,10 +885,9 @@ describe Projects::MergeRequestsController do environment2 = create(:environment, project: forked) create(:deployment, :succeed, environment: environment2, sha: sha, ref: 'master', deployable: build) - # TODO address the last 11 queries + # TODO address the last 5 queries # See https://gitlab.com/gitlab-org/gitlab-ce/issues/63952 (5 queries) - # And https://gitlab.com/gitlab-org/gitlab-ce/issues/64105 (6 queries) - leeway = 11 + leeway = 5 expect { get_ci_environments_status }.not_to exceed_all_query_limit(control_count + leeway) end end diff --git a/spec/models/deployment_metrics_spec.rb b/spec/models/deployment_metrics_spec.rb index 0aadb1f3a5e..7c574a8b6c8 100644 --- a/spec/models/deployment_metrics_spec.rb +++ b/spec/models/deployment_metrics_spec.rb @@ -49,18 +49,6 @@ describe DeploymentMetrics 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 -- cgit v1.2.1