-
Notifications
You must be signed in to change notification settings - Fork 63
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
Add persistor with configurable saver strategy #73
Add persistor with configurable saver strategy #73
Conversation
91d0489
to
e7b0d2f
Compare
:parent => manager, | ||
:builder_params => {:ems_id => manager.id}, | ||
:association => :container_routes, | ||
:attributes_blacklist => [:namespace, :tags], |
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.
@cben I needed to blacklist tags to have OSE test passing, is there some other change that doesn't require this?
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.
Hmm, didn't notice parse_*
functions are setting tags. I'm surprised it worked so far without the blacklist :-)
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.
It might have been a bad rebase, because it was there and then I noticed it was missing when I rebased yesterday. Without it, the OpenShift specs were failing for me.
This pull request is not mergeable. Please rebase and repush. |
Expose shared options of the existing ICs and make a Persister connection.
Use a Persistor in the Parser
Make InventoryCollections configurable by Settings
Test :default and :batch saver strategies
Blacklist tags for container routes and builds
Deduplicate spec before blocks
Remove image labels as those are conditionally in the OSE parser
Extract persister class, so it can be redefined by OpenShift
e7b0d2f
to
f22f947
Compare
ContainerService id is part of the ContainerServicePortConfig ems_ref
Add todo for :protocol inside of ContainerServicePortConfig manager_ref
Checked commits Ladas/manageiq-providers-kubernetes@07971aa~...0af5990 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 app/models/manageiq/providers/kubernetes/container_manager/refresh_parser.rb
|
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.
Excellent 👍 some small questions
Made me read the base inventory.rb, inventory/persister.rb, so I finally have some idea what these do :-)
initialize_inventory_collections(ems, options) | ||
persister = ManageIQ::Providers::Kubernetes::Inventory::Persister::ContainerManager.new(ems) | ||
# TODO expose Persistor and use that | ||
@inv_collections = persister.collections |
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.
https://english.stackexchange.com/questions/206893/persister-or-persistor ?
(unconclusive, some anecdotal usage but no etymological basis for distinct meanings)
{ | ||
:strategy => strategy, | ||
:targeted => targeted, | ||
:saver_strategy => saver_strategy |
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.
So if you don't set saver_strategy in settings, would it still use default
or is it a mandatory setting now?
Can you add the possible/interesting options to settings.yml? Or are there too many to list?
At least saver_strategy? I'd like at least those settings we expect performance team to measure to appear in Advanced Settings.
context "with :batch saver" do | ||
before(:each) do | ||
stub_settings_merge( | ||
:ems_refresh => {:kubernetes => {:inventory_collections => {:saver_strategy => :batch}}} |
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.
Will it work with string "batch"
as more likely to come from settings.yml ? (I think our settings parser does understand :symbol
syntax but I don't want to require it.)
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.
Settings can handle symbol, we use in on few places now. But yeah, the interface should probably handle string too. Should be done in coming PRs, where I will be refactoring the interface.
@@ -41,8 +40,12 @@ def ems_inv_to_hashes(inventory, _options = Config::Options.new) | |||
@data | |||
end | |||
|
|||
def persister_class | |||
ManageIQ::Providers::Kubernetes::Inventory::Persister::ContainerManager |
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.
A job for Inventory.persister_class_for()
?
(I'm actually happy as written — less magic to follow, but if you already have the magic lookup pattern in other places...)
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.
possibly, but the next step should be to expose persistor, instead of @inv_collections. So yeah, we could abstract that on the Inventory.
codeclimate is all about InventoryCollection construction, ignorable. |
@miq-bot add-label performance |
@moolitayer @enoodle @zeari please review. |
def ems_inv_to_inv_collections(ems, inventory, options = Config::Options.new) | ||
initialize_inventory_collections(ems, options) | ||
persister = persister_class.new(ems) | ||
# TODO expose Persistor and use that |
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.
@Ladas can you please explain this TODO?
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.
just that we should replace the usage of @inv_collections, that we have in many files by the Persister object, that should be the interface
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.
ahh okay, was a little confused by the fact that here the todo is already done...
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, we just need to fix all the other places. :-)
end | ||
|
||
def shared_options | ||
settings_options = options[:inventory_collections].try(:to_hash) || {} |
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.
Where is options coming from?
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.
that is on a base class Persistor, taking it from the advanced settings
|
||
settings_options.merge( | ||
:strategy => strategy, | ||
:targeted => targeted, |
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.
Is it intentional these two can't be configured?
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.
yes, those 2 will be overwritten by the Persistor class used for subgraph saving. The interface itself, I still need to redesign it, trying to figure it out now. :-)
end | ||
|
||
def strategy | ||
nil |
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.
what is the meaning of a nil strategy ? can we be explicit ?
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.
This is the DB searching strategy, default is nil. We will redefine it for the sub-graph saving Persistor
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.
oh I see it on InventoryCollection now, nice doc!
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 need to refactor those though, since the number of settings to cover all the corner cases has grown a lot :-) So that interface + connection to Settings refactoring is on the roadmap next.
:association => :container_services, | ||
:secondary_refs => {:by_namespace_and_name => [:namespace, :name]}, | ||
:attributes_blacklist => [:namespace], | ||
:saver_strategy => :default # TODO(perf) Can't use batch strategy because of usage of M:N container_groups relation |
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.
M:N = M:M ? if not what does it mean?
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.
the relation table container_groups_container_services, we need to model it as a separate InventoryCollection, then the batch saving will work, for both container_groups and container_groups_container_services
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.
LGTM 👍
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.
LGTM 👍
BTW @Ladas it would be nice to have an empty |
@moolitayer right, I haven't figured out the exact format yet, once i do, I'll push it to the settings. We will probably need to be able to set the option for specific Persistor and specific InventoryCollection. |
@moolitayer Any reason there's no milestone here? |
@bdunne see #72 (comment) |
there's no particular reason, just update for update sake https://github.com/ManageIQ/more_core_extensions/compare/179bf40..e5b4501 - Added Ruby 2.7 support [[ManageIQ#79](ManageIQ/more_core_extensions#79)] - Added Process#pause, Process#resume, and Process#alive? [[ManageIQ#73](ManageIQ/more_core_extensions#73)] array added * `#compact_map` - Collect non-nil results from the block array added `#tabular_sort` - Sorts an Array of Hashes by specific columns hierarchy added `#descendant_get` - Returns the descendant with a given name the two breaking changes: - **BREAKING**: Moved Object#descendant_get to Class#descendant_get [[ManageIQ#75](ManageIQ/more_core_extensions#75)] - **BREAKING**: Removed deprecated Enumerable#stable_sort_by [[ManageIQ#76](ManageIQ/more_core_extensions#76)] a minor header output change was made that hasn't been released yet to make tableize more markdown compliant see ManageIQ/linux_admin#221
there's no particular reason, just update for update sake https://github.com/ManageIQ/more_core_extensions/compare/179bf40..e5b4501 - Added Ruby 2.7 support [[ManageIQ#79](ManageIQ/more_core_extensions#79)] - Added Process#pause, Process#resume, and Process#alive? [[ManageIQ#73](ManageIQ/more_core_extensions#73)] array added * `#compact_map` - Collect non-nil results from the block array added `#tabular_sort` - Sorts an Array of Hashes by specific columns hierarchy added `#descendant_get` - Returns the descendant with a given name the two breaking changes: - **BREAKING**: Moved Object#descendant_get to Class#descendant_get [[ManageIQ#75](ManageIQ/more_core_extensions#75)] - **BREAKING**: Removed deprecated Enumerable#stable_sort_by [[ManageIQ#76](ManageIQ/more_core_extensions#76)] a minor header output change was made that hasn't been released yet to make tableize more markdown compliant see ManageIQ/linux_admin#221
there's no particular reason, just update for update sake https://github.com/ManageIQ/more_core_extensions/compare/179bf40..e5b4501 - Added Ruby 2.7 support [[ManageIQ#79](ManageIQ/more_core_extensions#79)] - Added Process#pause, Process#resume, and Process#alive? [[ManageIQ#73](ManageIQ/more_core_extensions#73)] array added * `#compact_map` - Collect non-nil results from the block array added `#tabular_sort` - Sorts an Array of Hashes by specific columns hierarchy added `#descendant_get` - Returns the descendant with a given name the two breaking changes: - **BREAKING**: Moved Object#descendant_get to Class#descendant_get [[ManageIQ#75](ManageIQ/more_core_extensions#75)] - **BREAKING**: Removed deprecated Enumerable#stable_sort_by [[ManageIQ#76](ManageIQ/more_core_extensions#76)] a minor header output change was made that hasn't been released yet to make tableize more markdown compliant see ManageIQ/linux_admin#221
Add Persistor with configurable saver strategy. Encapsulating ICs to Persistor and exposing the options to Settings. Testing both ;default and :batch strategies
Check with https://github.com/ManageIQ/manageiq-providers-kubernetes/pull/73/files?w=1 to filter out the whitespace changes