Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache node_types instead of calling on every request #14922

Merged
merged 1 commit into from
Jun 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions app/models/ems_cluster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,14 @@ def register_host(host)
end
end

def self.node_types
return :non_openstack unless openstack_clusters_exists?
non_openstack_clusters_exists? ? :mixed_clusters : :openstack
cache_with_timeout(:node_types) do
if !openstack_clusters_exists?
:non_openstack
elsif non_openstack_clusters_exists?
:mixed_clusters
else
:openstack
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with this but it still feels like this is wrong. We should have cross cloud terminology, a combination of all the things, or a place for them to choose the wording. The fact that we query the database, have lots of backend and UI code to try to figure out what to call things in the UI amazes me. cc @chessbyte

end

def self.openstack_clusters_exists?
Expand Down
11 changes: 8 additions & 3 deletions app/models/host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1813,9 +1813,14 @@ def has_compliance_policies?
!plist.blank?
end

def self.node_types # TODO: This doesn't belong here
return :non_openstack unless openstack_hosts_exists?
non_openstack_hosts_exists? ? :mixed_hosts : :openstack
cache_with_timeout(:node_types) do # TODO: This doesn't belong here
if !openstack_hosts_exists?
:non_openstack
elsif non_openstack_hosts_exists?
:mixed_hosts
else
:openstack
end
end

def self.openstack_hosts_exists? # TODO: This doesn't belong here
Expand Down