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

Add persistor with configurable saver strategy #73

Merged

Conversation

Ladas
Copy link
Contributor

@Ladas Ladas commented Jul 25, 2017

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

@Ladas
Copy link
Contributor Author

Ladas commented Jul 25, 2017

cc @agrare @cben

@Ladas Ladas closed this Jul 25, 2017
@Ladas Ladas reopened this Jul 25, 2017
@Ladas Ladas force-pushed the add_persistor_with_configurable_saver_strategy branch 2 times, most recently from 91d0489 to e7b0d2f Compare July 26, 2017 09:52
:parent => manager,
:builder_params => {:ems_id => manager.id},
:association => :container_routes,
:attributes_blacklist => [:namespace, :tags],
Copy link
Contributor Author

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?

Copy link
Contributor

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 :-)

Copy link
Contributor Author

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.

@miq-bot
Copy link
Member

miq-bot commented Jul 26, 2017

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

agrare and others added 9 commits July 27, 2017 09:44
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
@Ladas Ladas force-pushed the add_persistor_with_configurable_saver_strategy branch from e7b0d2f to f22f947 Compare July 27, 2017 07:51
ContainerService id is part of the ContainerServicePortConfig ems_ref
Add todo for :protocol inside of ContainerServicePortConfig manager_ref
@miq-bot
Copy link
Member

miq-bot commented Jul 27, 2017

Checked commits Ladas/manageiq-providers-kubernetes@07971aa~...0af5990 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
6 files checked, 1 offense detected

app/models/manageiq/providers/kubernetes/container_manager/refresh_parser.rb

  • ❗ - Line 49, Col 9 - Style/CommentAnnotation - Annotation keywords like TODO should be all upper case, followed by a colon, and a space, then a note describing the problem.

Copy link
Contributor

@cben cben left a 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
Copy link
Contributor

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
Copy link
Contributor

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}}}
Copy link
Contributor

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.)

Copy link
Contributor Author

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
Copy link
Contributor

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...)

Copy link
Contributor Author

@Ladas Ladas Jul 27, 2017

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.

@cben
Copy link
Contributor

cben commented Jul 27, 2017

codeclimate is all about InventoryCollection construction, ignorable.

@cben
Copy link
Contributor

cben commented Jul 27, 2017

@miq-bot add-label performance
(a lot of performance :-)

@cben cben mentioned this pull request Jul 27, 2017
24 tasks
@cben
Copy link
Contributor

cben commented Jul 27, 2017

@moolitayer @enoodle @zeari please review.
(?w=1 link in PR description helps.)

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

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?

Copy link
Contributor Author

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

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...

Copy link
Contributor Author

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) || {}

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?

Copy link
Contributor Author

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,

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?

Copy link
Contributor Author

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

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 ?

Copy link
Contributor Author

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

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!

Copy link
Contributor Author

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

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?

Copy link
Contributor Author

@Ladas Ladas Jul 27, 2017

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

Copy link

@moolitayer moolitayer left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link

@moolitayer moolitayer left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@moolitayer moolitayer merged commit 0f62a51 into ManageIQ:master Jul 27, 2017
@moolitayer
Copy link

BTW @Ladas it would be nice to have an empty inventory_collections in the settings for visibility

@Ladas
Copy link
Contributor Author

Ladas commented Jul 27, 2017

@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.

@bdunne
Copy link
Member

bdunne commented Aug 8, 2017

@moolitayer Any reason there's no milestone here?

@moolitayer
Copy link

@bdunne see #72 (comment)

@moolitayer moolitayer added this to the Sprint 66 Ending Aug 7, 2017 milestone Aug 9, 2017
d-m-u added a commit to d-m-u/manageiq-providers-kubernetes that referenced this pull request Jun 29, 2020
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
d-m-u added a commit to d-m-u/manageiq-providers-kubernetes that referenced this pull request Jul 14, 2020
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
d-m-u added a commit to d-m-u/manageiq-providers-kubernetes that referenced this pull request Jul 14, 2020
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
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.

6 participants