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

Use the new OvirtSDK for refresh #14398

Merged
merged 3 commits into from
Mar 27, 2017

Conversation

borod108
Copy link

If the ovirt provider supports version 4 of the api use the new
OvirtSDK to do refresh and targeted refresh.

(This is a first in a series of PRs that will allow using the OvirtSDK with providers that support version 4 for refresh, event handling and provisioning.)

If the ovirt provider supports version 4 of the api use the new
OvirtSDK to do refresh and targeted refresh.
@borod108 borod108 changed the title [WIP] Use the new OvitSDK for refresh Use the new OvitSDK for refresh Mar 19, 2017
@borod108
Copy link
Author

@pkliczewski @masayag please review.

Add a setting that by default will disable the use of the OvirtSDK for
refresh and provisioning.
@chessbyte chessbyte changed the title Use the new OvitSDK for refresh Use the new OvirtSDK for refresh Mar 20, 2017
@@ -101,6 +101,7 @@
:omit_default_port: true
:read_timeout: 60
:ems_redhat:
:use_ovirt_engine_sdk: false
Copy link
Member

Choose a reason for hiding this comment

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

Not a fan of adding another option. When would a customer ever turn this on?

Copy link
Author

Choose a reason for hiding this comment

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

The idea is that we want to get the code in and allow people who want to try it to use it but if there are problems they can turn it off. Its off by default as a safety measure.
One might want to turn this on if he wants better performance due to the improved sdk for example.
When it is tested enough the default will be true and when the old api is not supported anymore it will just be removed.

Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member

Choose a reason for hiding this comment

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

@Fryguy @blomquisg exactly. This feature toggle is basically the same approach we took for the graph refresh in amazon.

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.

Basically ok with the feature toggle approach.

@borod108 could you explain a bit, how the current refresh code is still used? Although you dont delete much existing code you still introduce a bunch of V3 code...

other suggestions as comments

@blomquisg this is intended to go into Fine. In the end this is you call, but we discussed it's ok with the feature toggle approach

@@ -101,6 +101,7 @@
:omit_default_port: true
:read_timeout: 60
:ems_redhat:
:use_ovirt_engine_sdk: false
Copy link
Member

Choose a reason for hiding this comment

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

@Fryguy @blomquisg exactly. This feature toggle is basically the same approach we took for the graph refresh in amazon.

@@ -9,6 +9,7 @@
@ems.default_endpoint.path = "/ovirt-engine/api"
allow(@ems).to receive(:supported_api_versions).and_return([3, 4])
allow(@ems).to receive(:resolve_ip_address).with(ip_address).and_return(ip_address)
::Settings.ems.ems_redhat.use_ovirt_engine_sdk = true
Copy link
Member

Choose a reason for hiding this comment

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

this should use stub_settings - otherwise you are modifying the Settings singleton and it will be true for others as well

@@ -5,6 +5,7 @@
:port => 8443)
@ems.update_authentication(:default => {:userid => "admin@internal", :password => "123456"})
allow(@ems).to receive(:supported_api_versions).and_return([3, 4])
::Settings.ems.ems_redhat.use_ovirt_engine_sdk = true
Copy link
Member

Choose a reason for hiding this comment

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

stub_settings too - see below

Copy link
Author

Choose a reason for hiding this comment

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

right!

subject { described_class.new(ems, options).build }
describe 'chooses the right parsing strategy' do
before do
::Settings.ems.ems_redhat.use_ovirt_engine_sdk = use_ovirt_engine_sdk
Copy link
Member

Choose a reason for hiding this comment

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

stub_settings - see below

Copy link
Author

Choose a reason for hiding this comment

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

right!

end

def host_targeted_refresh(target)
@ems.with_provider_connection(:version => 4) do |connection|
Copy link
Member

Choose a reason for hiding this comment

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

I'd use the attr_reader ems if you already have it

Copy link
Author

Choose a reason for hiding this comment

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

right!

@@ -0,0 +1,63 @@
module ManageIQ::Providers::Redhat::InfraManager::Refresh::Parse::Strategies
class DatacenterInventory
attr_reader :datacenter_inv, :_log
Copy link
Member

Choose a reason for hiding this comment

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

_log will mask _log here

Copy link
Author

Choose a reason for hiding this comment

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

right!

@miq-bot
Copy link
Member

miq-bot commented Mar 22, 2017

Some comments on commits borod108/manageiq@ccb1cf8~...7e639d3

spec/models/manageiq/providers/redhat/infra_manager/refresh/refresher_4_1_spec.rb

  • ⚠️ - 23 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.
  • ⚠️ - 25 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.
  • ⚠️ - 27 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.
  • ⚠️ - 29 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.
  • ⚠️ - 31 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.
  • ⚠️ - 33 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.
  • ⚠️ - 35 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.
  • ⚠️ - 37 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.
  • ⚠️ - 38 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.

spec/models/manageiq/providers/redhat/infra_manager/refresh/refresher_target_vm_4_spec.rb

  • ⚠️ - 27 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.
  • ⚠️ - 29 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.
  • ⚠️ - 31 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.
  • ⚠️ - 33 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.
  • ⚠️ - 35 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.
  • ⚠️ - 37 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.
  • ⚠️ - 38 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.

@miq-bot
Copy link
Member

miq-bot commented Mar 22, 2017

Checked commits borod108/manageiq@ccb1cf8~...7e639d3 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
22 files checked, 41 offenses detected

app/models/manageiq/providers/redhat/infra_manager/refresh/parse/strategies/vm_inventory.rb

spec/models/manageiq/providers/redhat/infra_manager/event_parser_spec.rb

spec/models/manageiq/providers/redhat/infra_manager/refresh/parse/parser_builder_spec.rb

spec/models/manageiq/providers/redhat/infra_manager/refresh/refresher_4_1_spec.rb

@borod108
Copy link
Author

@Fryguy @blomquisg @durandom please note that when the setting use_ovirt_engine_sdk is set to false it the code that will be used is the old code for both collecting th einventory and parsing.

A little more details: this: https://github.com/ManageIQ/manageiq/pull/14398/files#diff-d6125c21d43685840429020f8c5a57aaR233
will return "3"
and so this: https://github.com/ManageIQ/manageiq/pull/14398/files#diff-119cc54f84ee5e4e6e981fc798938f8aR12 will use the parser api3 version which is exactly the old code for parsing.
and for refreshing the same happens here: https://github.com/ManageIQ/manageiq/pull/14398/files#diff-56e54a726f15e610eec31cddfb4b0682
the refresher just hold the targeted_refresh functions which were moved there and inventory_from_ovirt(ems) is overridden in api4 of the refresher but returns the old Ovirt::Inventory for
version api3 of the refresher.
So when the switch is turned off (as by default) the code that does the refresh and parsing is actually the same.
The uni-tests pass for both versions and we have being testing this manually as well for a while now.

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.

👍
QE also tested this part extensively and found no regressions

@blomquisg please merge

@durandom
Copy link
Member

@miq-bot add_labels enhancement

@blomquisg blomquisg merged commit e7656ce into ManageIQ:master Mar 27, 2017
@blomquisg blomquisg added this to the Sprint 57 Ending Mar 27, 2017 milestone Mar 27, 2017
borod108 pushed a commit to borod108/manageiq that referenced this pull request Apr 6, 2017
…e_sdk setting

and will not use OvirtSDK if it is off.

This was a common effort with big contribution from @pkliczewski
and help from @jhernand and @masayag

This PR is based on: ManageIQ#14398
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.

7 participants