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

[WIP] Using the new tag mapping for graph refresh #384

Closed
wants to merge 2 commits into from
Closed

[WIP] Using the new tag mapping for graph refresh #384

wants to merge 2 commits into from

Conversation

juliancheal
Copy link
Member

Fixes BZ https://bugzilla.redhat.com/show_bug.cgi?id=1506404

Tag mapping is missing for Amazon Graph refresh.

@bronaghs bronaghs requested a review from Ladas January 2, 2018 16:31
@juliancheal
Copy link
Member Author

juliancheal commented Jan 2, 2018

I'm currently getting this error.

EmsRefresh::Refreshers::EmsRefresherMixin::PartialRefreshError: undefined method `[]' for nil:NilClass

from

manageiq/app/models/ems_refresh/refreshers/ems_refresher_mixin.rb:50:in `refresh'

@juliancheal
Copy link
Member Author

I'm not sure if I'm parsing the tags into the correct format expected? @Ladas @cben

@cben
Copy link
Contributor

cben commented Jan 2, 2018

manageiq/app/models/ems_refresh/refreshers/ems_refresher_mixin.rb:50:in `refresh'

Line 50 is notorious as a front, hiding all the shady business going on in refresh :-) 🚪 🎰
Try setting EmsRefresh.debug_failures = true to see the actual exception.

I'll also run this now.

:section => section,
:name => tag["key"],
:value => tag["value"],
:source => source
Copy link
Contributor

Choose a reason for hiding this comment

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

If you only use this function to feed map_labels, you only need :name and :value.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok thanks!

@juliancheal
Copy link
Member Author

Line 50 is notorious as a front, hiding all the shady business going on in refresh :-) 🚪 🎰
Try setting EmsRefresh.debug_failures = true to see the actual exception.

I'll also run this now.

Ok so it's showing the error as

NoMethodError: undefined method `[]' for nil:NilClass
/manageiq-providers-amazon/app/models/manageiq/providers/amazon/inventory/parser/cloud_manager.rb:231:in `map_taggings'

@juliancheal
Copy link
Member Author

In case it helps, this is the data I'm passing to map_taggings

parent:

InventoryObject:('i-07cf95973c3875be3', InventoryCollection:<ManageIQ::Providers::Amazon::CloudManager::Vm>, blacklist: [genealogy_parent])

tags_inventory_objects:

[InventoryObject:('141__yipikaye__yipikaye', InventoryCollection:<Tag>)]

def map_taggings(parent, tags_inventory_objects)
model_name = parent.inventory_collection.model_class.base_class.name
key = [:taggings_for, model_name]
collection = @inv_collections[key]
Copy link
Contributor

@Ladas Ladas Jan 2, 2018

Choose a reason for hiding this comment

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

there are no @inv_collections[key]

first, you need to add the inv collection as @cben is doing it https://github.com/ManageIQ/manageiq-providers-kubernetes/pull/162/files#diff-26f0b75803f05ef203ec5099294834dfR380
then the collection will be here as in @collections

then call it e.g. as persister.taggings_for_vm

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

btw. NoMethodError: undefined method `[]' for nil:NilClass is because @inv_collections are nil

We have @collections here, but we should not access it directly, that is why we call it as persister.collection_name

But unless you place it on @collections[collection.name] = InventoryCollection.new..., it will not be there

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the taggings collections can be added in app/models/manageiq/providers/amazon/inventory_collection_default/cloud_manager.rb similar to vm_and_template_labels (and called from https://github.com/Ladas/manageiq-providers-amazon/blob/f9123d84236a66348c4bd05d499c74f94f6d7594/app/models/manageiq/providers/amazon/inventory/persister/cloud_manager.rb#L5)
playing with that now...

Also need to add persistor.add_inventory_collection(@tag_mapper.tags_to_resolve_collection) somewhere.

Copy link
Contributor

@Ladas Ladas Jan 3, 2018

Choose a reason for hiding this comment

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

@Ladas
Copy link
Contributor

Ladas commented Jan 2, 2018

@juliancheal
Copy link
Member Author

calling, persister.taggings_for_vm just results in

NoMethodError: undefined method `taggings_for_vm for
<ManageIQ::Providers::Amazon::Inventory::Persister::CloudManager

@juliancheal
Copy link
Member Author

I've added @cben's specs to my PR and implemented more of the code you both suggested.

@cben
Copy link
Contributor

cben commented Jan 3, 2018

I think you forgot to git push?
(we're somewhat duplicating efforts, but I don't mind, in the end we'll converge to something that (1) works (2) we both understand ;-)

@juliancheal
Copy link
Member Author

@cben I think I'm following along. Your PR #382 seems much better now than mine :(

@miq-bot miq-bot added the wip label Jan 3, 2018
@miq-bot
Copy link
Member

miq-bot commented Jan 3, 2018

Checked commits https://github.com/juliancheal/manageiq-providers-amazon/compare/6a212ee93fa1f48b9b62fb043b27c094c5dbfb4f~...58c2ab1f4db689fb066c1b3a817d8389239ef2cb with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0
1 file checked, 8 offenses detected

app/models/manageiq/providers/amazon/inventory/parser/cloud_manager.rb

@cben cben mentioned this pull request Jan 3, 2018
1 task
@juliancheal juliancheal closed this Jan 4, 2018
@juliancheal
Copy link
Member Author

Superseded by #382

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants