Skip to content
Snippets Groups Projects
Commit 35994fe0 authored by Nick Thomas's avatar Nick Thomas
Browse files

Merge branch '65963-avoid-extra-query-allowed-to-uninstall' into 'master'

Fix a performance issue in Helm#can_uninstall?

Closes #65963

See merge request gitlab-org/gitlab-ce!31751
parents 266211b9 dcdc04ab
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -41,7 +41,7 @@ module Clusters
 
extra_apps = Clusters::Applications::Helm.where('EXISTS (?)', klass.select(1).where(cluster_id: cluster_id))
 
applications = applications.present? ? applications.or(extra_apps) : extra_apps
applications = applications ? applications.or(extra_apps) : extra_apps
end
 
!applications.exists?
Loading
Loading
Loading
Loading
@@ -23,7 +23,7 @@ describe Clusters::Applications::Helm do
Clusters::Cluster::APPLICATIONS.keys.each do |application_name|
next if application_name == 'helm'
 
it do
it "is false when #{application_name} is installed" do
cluster_application = create("clusters_applications_#{application_name}".to_sym)
 
helm = cluster_application.cluster.application_helm
Loading
Loading
@@ -31,6 +31,14 @@ describe Clusters::Applications::Helm do
expect(helm.allowed_to_uninstall?).to be_falsy
end
end
it 'executes a single query only' do
cluster_application = create(:clusters_applications_ingress)
helm = cluster_application.cluster.application_helm
query_count = ActiveRecord::QueryRecorder.new { helm.allowed_to_uninstall? }.count
expect(query_count).to eq(1)
end
end
 
context "without other existing applications" do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment