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

Fix fallouts from ContainerTemplate STI #81

Merged
merged 2 commits into from
Aug 3, 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class ManageIQ::Providers::Kubernetes::ContainerManager < ManageIQ::Providers::C
require_nested :Container
require_nested :ContainerGroup
require_nested :ContainerNode
require_nested :ContainerTemplate
require_nested :EventCatcher
require_nested :EventCatcherMixin
require_nested :EventParser
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,10 @@ def initialize_inventory_collections
# ContainerCondition is polymorphic child of ContainerNode & ContainerGroup.
def initialize_container_conditions_collection(relation)
query = ContainerCondition.where(
:container_entity_type => relation.model.name,
:container_entity_type => relation.model.base_class.name,
:container_entity_id => relation, # nested SELECT. TODO: compare to a JOIN.
)
@collections[[:container_conditions_for, relation.model.name]] =
@collections[[:container_conditions_for, relation.model.base_class.name]] =
::ManagerRefresh::InventoryCollection.new(
shared_options.merge(
:model_class => ContainerCondition,
Expand All @@ -342,11 +342,11 @@ def initialize_container_conditions_collection(relation)
def initialize_custom_attributes_collections(relation, sections)
sections.each do |section|
query = CustomAttribute.where(
:resource_type => relation.model.name,
:resource_type => relation.model.base_class.name,
:resource_id => relation,
:section => section.to_s
)
@collections[[:custom_attributes_for, relation.model.name, section.to_s]] =
@collections[[:custom_attributes_for, relation.model.base_class.name, section.to_s]] =
::ManagerRefresh::InventoryCollection.new(
shared_options.merge(
:model_class => CustomAttribute,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def get_pods_graph(inv)

# polymorphic, relation disambiguates parent
def get_container_conditions_graph(parent, hashes)
model_name = parent.inventory_collection.model_class.name
model_name = parent.inventory_collection.model_class.base_class.name

Choose a reason for hiding this comment

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

we don't need base class here right? (since the classes use in collections are already basic)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right we shouldn't need it, but experimentally we do :-\ Without it, in ManageIQ/manageiq-providers-openshift#28 refresher specs,
I get weird Invalid single-table inheritance type: ManageIQ::Providers::Openshift::ContainerManager::ContainerTemplate is not a subclass of ManageIQ::Providers::ContainerManager::ContainerTemplate

This parent-sniffing magic is too fragile, I'm gonna replace it with something more explicit (plus give inventory collections unique .names for debugging). But for now let's get back to green.

hashes.to_a.each do |h|
h = h.merge(:container_entity => parent)
@inv_collections[[:container_conditions_for, model_name]].build(h)
Expand Down Expand Up @@ -554,7 +554,7 @@ def get_container_images_graph
end

def get_custom_attributes_graph(parent, hashes_by_section)
model_name = parent.inventory_collection.model_class.name
model_name = parent.inventory_collection.model_class.base_class.name
hashes_by_section.each do |section, hashes|
key = [:custom_attributes_for, model_name, section.to_s]
collection = @inv_collections[key]
Expand Down