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

Separate collector from inventory and targeted refresh #115

Merged
merged 5 commits into from
Feb 2, 2017

Conversation

Ladas
Copy link
Contributor

@Ladas Ladas commented Jan 25, 2017

Separate collector from inventory, Collector class focus directly on collecting related data from a provider. Introduce targeted refresh.

@miq-bot
Copy link
Member

miq-bot commented Jan 25, 2017

This pull request is not mergeable. Please rebase and repush.

Separate a Collector from an Inventory. A collector class takes
care of data collection from a provider while inventory
creates InventoryCollections and associates right Collector object
Remove EventPayloadVm target, we don't use it anymore.
@Ladas Ladas force-pushed the separate_collector_from_inventory branch from 0cdd04f to be66154 Compare January 26, 2017 23:12
@Ladas Ladas changed the title Separate collector from inventory Separate collector from inventory and targeted refresh Jan 27, 2017
@Ladas Ladas force-pushed the separate_collector_from_inventory branch 2 times, most recently from 7c5c1b4 to c19ca78 Compare January 31, 2017 10:02
Copy link
Member

@durandom durandom left a comment

Choose a reason for hiding this comment

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

I like the collector approach and having Inventory classes for every possible target.

But still, this PR does too many things. The most controversial part being the EmsEvent as a target and hence the need for a TargetCollection

Sorry, but I'd like to see that split into smaller PRs still.

Maybe

  • modelling the Collector/Target/Inventory thing first in the core on a smaller ansible provider
  • moving that modelling over here to aws
  • finally think about the EmsEvent as a target

wdyt>

@@ -26,6 +26,15 @@ def parse_targeted_inventory(ems, _target, inventory)
hashes, = Benchmark.realtime_block(:parse_inventory) do
if refresher_options.try(:[], :inventory_object_refresh)
ManageIQ::Providers::Amazon::CloudManager::RefreshParserInventoryObject.new(inventory).populate_inventory_collections
Copy link
Member

Choose a reason for hiding this comment

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

so, what does this do? I guess its a leftover?

Copy link
Member

Choose a reason for hiding this comment

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

oh no, it's because this manipulates inventory

@@ -26,6 +26,15 @@ def parse_targeted_inventory(ems, _target, inventory)
hashes, = Benchmark.realtime_block(:parse_inventory) do
if refresher_options.try(:[], :inventory_object_refresh)
Copy link
Member

Choose a reason for hiding this comment

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

probably you could even get rid of this. Because inventory is always nil for the old refresh

if inventory.kind_of?(ManageIQ::Providers::Amazon::Inventory::Targets::TargetCollection)
# For EmsEventCollection, we want to parse everything, regardless whether it belongs to Cloud or Network
# Manager
ManageIQ::Providers::Amazon::NetworkManager::RefreshParserInventoryObject.new(inventory).populate_inventory_collections
Copy link
Member

Choose a reason for hiding this comment

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

so, this feels somehow wrong.
Because you use RefreshParserInventoryObject to manipulate inventory right?

@@ -35,6 +44,29 @@ def parse_targeted_inventory(ems, _target, inventory)
hashes
end

def preprocess_targets
Copy link
Member

Choose a reason for hiding this comment

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

For now its ok, but I dont think we should allow this to be overriden

_log.info "Defaulting to full refresh for EMS: [#{ems.name}], id: [#{ems.id}], from targets: #{targets_for_log}" if targets.length > 1
end

# We want all targets of class EmsEvent to be merged into one target, so they can be refreshed together, otherwise
Copy link
Member

Choose a reason for hiding this comment

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

So, this thing about EmsEvent being a target. Is ManageIQ/manageiq#13408 needed for this to work?

@@ -0,0 +1,126 @@
class ManageIQ::Providers::Amazon::Inventory::Collectors
Copy link
Member

Choose a reason for hiding this comment

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

I dont like this class being a plural. It should be Collector

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we can do singular, I have there Targets and Collectors

initialize_inventory_sources
end

def initialize_inventory_sources
Copy link
Member

Choose a reason for hiding this comment

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

So every collector has all this? Shouldnt it be per Subclass different?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, we need is always defined, so by default all data are []

@@ -1,4 +1,9 @@
class ManageIQ::Providers::Amazon::Inventory::Targets < ManageIQ::Providers::Amazon::Inventory
Copy link
Member

Choose a reason for hiding this comment

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

Same here, why is that a plural class name? And why does it inherit from Inventory ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The target is really an inventory here

We can revisit that Inventory could have target and collector

CloudManager target typo
CloudManager collector rubocop issue
All refs in base collector are a Set, so they check uniqueness
by default. Also adding base entries for block storage models.
@Ladas Ladas force-pushed the separate_collector_from_inventory branch from 31149cd to 443ef96 Compare February 1, 2017 13:31
@miq-bot
Copy link
Member

miq-bot commented Feb 1, 2017

Checked commits Ladas/manageiq-providers-amazon@5533c2d~...443ef96 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
16 files checked, 6 offenses detected

app/models/manageiq/providers/amazon/inventory/collectors.rb

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

  • ❗ - Line 20, Col 55 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.
  • ❗ - Line 26, Col 55 - Style/AlignHash - Align the elements of a hash literal if they span more than one line.

app/models/manageiq/providers/amazon/inventory/collectors/network_manager.rb

app/models/manageiq/providers/amazon/inventory/targets.rb

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

@durandom durandom merged commit dc8e18e into ManageIQ:master Feb 2, 2017
@durandom
Copy link
Member

durandom commented Feb 2, 2017

merging to move forward ontop of this

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

Successfully merging this pull request may close these issues.

3 participants