-
Notifications
You must be signed in to change notification settings - Fork 107
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
Amazon S3 objects inventoring #123
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 29 additions & 27 deletions
56
app/models/manageiq/providers/amazon/storage_manager/s3/refresher.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,41 @@ | ||
class ManageIQ::Providers::Amazon::StorageManager::S3::Refresher < ManageIQ::Providers::BaseManager::Refresher | ||
include ::EmsRefresh::Refreshers::EmsRefresherMixin | ||
module ManageIQ::Providers | ||
class Amazon::StorageManager::S3::Refresher < ManageIQ::Providers::BaseManager::Refresher | ||
include ::EmsRefresh::Refreshers::EmsRefresherMixin | ||
|
||
def collect_inventory_for_targets(ems, targets) | ||
targets_with_data = targets.collect do |target| | ||
target_name = target.try(:name) || target.try(:event_type) | ||
def collect_inventory_for_targets(ems, targets) | ||
targets_with_data = targets.collect do |target| | ||
target_name = target.try(:name) || target.try(:event_type) | ||
|
||
_log.info "Filtering inventory for #{target.class} [#{target_name}] id: [#{target.id}]..." | ||
_log.info "Filtering inventory for #{target.class} [#{target_name}] id: [#{target.id}]..." | ||
|
||
if refresher_options.try(:[], :inventory_object_refresh) | ||
inventory = ManageIQ::Providers::Amazon::Builder.build_inventory(ems, target) | ||
if refresher_options.try(:[], :inventory_object_refresh) | ||
inventory = ManageIQ::Providers::Amazon::Builder.build_inventory(ems, target) | ||
end | ||
|
||
_log.info "Filtering inventory...Complete" | ||
[target, inventory] | ||
end | ||
|
||
_log.info "Filtering inventory...Complete" | ||
[target, inventory] | ||
targets_with_data | ||
end | ||
|
||
targets_with_data | ||
end | ||
|
||
def parse_targeted_inventory(ems, _target, inventory) | ||
log_header = format_ems_for_logging(ems) | ||
_log.debug "#{log_header} Parsing inventory..." | ||
hashes, = Benchmark.realtime_block(:parse_inventory) do | ||
if refresher_options.try(:[], :inventory_object_refresh) | ||
inventory.inventory_collections | ||
else | ||
ManageIQ::Providers::Amazon::StorageManager::S3::RefreshParser.ems_inv_to_hashes(ems, refresher_options) | ||
def parse_targeted_inventory(ems, _target, inventory) | ||
log_header = format_ems_for_logging(ems) | ||
_log.debug "#{log_header} Parsing inventory..." | ||
hashes, = Benchmark.realtime_block(:parse_inventory) do | ||
if refresher_options.try(:[], :inventory_object_refresh) | ||
inventory.inventory_collections | ||
else | ||
ManageIQ::Providers::Amazon::StorageManager::S3::RefreshParser.ems_inv_to_hashes(ems, refresher_options) | ||
end | ||
end | ||
end | ||
_log.debug "#{log_header} Parsing inventory...Complete" | ||
_log.debug "#{log_header} Parsing inventory...Complete" | ||
|
||
hashes | ||
end | ||
hashes | ||
end | ||
|
||
def post_process_refresh_classes | ||
[] | ||
def post_process_refresh_classes | ||
[] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Old way of inventory refresh is not able to handle large amount of objects.
For example, 100k S3 objects handled by:
As far as removing old refresher is the question of time, we've decided to set the default setting to new mechanism usage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 I'll be doing the same for the other managers soon
hm, 2m vs. 2h, that is quite a bit difference, I wonder what makes it so slow in the old refresh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the time consumed on the next lines:
https://github.com/ManageIQ/manageiq/blob/master/app/models/ems_refresh/save_inventory_helper.rb#L55
https://github.com/ManageIQ/manageiq/blob/master/app/models/ems_refresh/save_inventory_helper.rb#L69
To reproduce that:
I've rejected idea of optimizing legacy parser's core.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I mean the new refresh is 'the optimization' :-D
but I think that in this case you are hitting a 5.0.1 Rails bug, the association.push has there a horrible O(n^2), it's already fixed in rails Master. So with that fixed, the number should not be that big for the old refresh. :-) Should be something around 15 minutes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can try by removing the 'unless @target.include?' here https://github.com/rails/rails/blob/v5.0.1/activerecord/lib/active_record/associations/collection_association.rb#L663
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, association.push is not the major problem there. Iterating through hash is the bigger problem. Like 80 / 20 (iterating hash with find or create / association push).
Yeah, and thanks for the optimized new refresh! It's complex, but at least pretty fast))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm you are right, for me it's 7500s vs 60s, with the rails fix applied. So something is really wrong in the old refresh