Skip to content

Commit

Permalink
Default to use streaming_refresh for vSphere
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Aug 8, 2019
1 parent 6f01348 commit 39ce0ce
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 50 deletions.
2 changes: 1 addition & 1 deletion app/models/manageiq/providers/vmware/infra_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def supported_catalog_types
end

def streaming_refresh_enabled?
Settings.prototype.ems_vmware.update_driven_refresh
Settings.ems_refresh.vmwarews.streaming_refresh
end

def remote_console_vmrc_acquire_ticket
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class ManageIQ::Providers::Vmware::InfraManager::RefreshWorker::Runner < ManageIQ::Providers::BaseManager::RefreshWorker::Runner
# When using update_driven_refresh we don't need to use the VimBrokerWorker
self.require_vim_broker = !Settings.prototype.ems_vmware.update_driven_refresh
self.delay_startup_for_vim_broker = !Settings.prototype.ems_vmware.update_driven_refresh
# When using streaming_refresh we don't need to use the VimBrokerWorker
self.require_vim_broker = !Settings.ems_refresh.vmwarews.streaming_refresh
self.delay_startup_for_vim_broker = !Settings.ems_refresh.vmwarews.streaming_refresh

def after_initialize
super
Expand Down Expand Up @@ -29,41 +29,23 @@ def do_work

private

attr_accessor :ems, :collector, :collector_thread
attr_accessor :ems, :collector

def start_inventory_collector
self.collector = ems.class::Inventory::Collector.new(ems)
self.collector_thread = Thread.new do
begin
collector.run
rescue => err
_log.error("Inventory collector aborted because [#{err.message}]")
_log.log_backtrace(err)
Thread.exit
end
end

collector.start
_log.info("Started inventory collector")
end

def ensure_inventory_collector
return if inventory_collector_running?
return if collector&.running?

_log.warn("Inventory collector thread not running, restarting...")
_log.warn("Inventory collector thread not running, restarting...") unless collector.nil?
start_inventory_collector
end

def stop_inventory_collector
collector.stop

# The WaitOptions for WaitForUpdatesEx call sets maxWaitSeconds to 60 seconds
collector_thread.join(60.seconds) # TODO: make this configurable

self.collector_thread = nil
collector&.stop(60.seconds)
self.collector = nil
end

def inventory_collector_running?
collector_thread&.alive?
end
end
2 changes: 1 addition & 1 deletion app/models/miq_ems_refresh_core_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class MiqEmsRefreshCoreWorker < MiqWorker
self.required_roles = ["ems_inventory"]

def self.has_required_role?
return false if Settings.prototype.ems_vmware.update_driven_refresh
return false if Settings.ems_refresh.vmwarews.streaming_refresh
super
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_vim_broker_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class MiqVimBrokerWorker < MiqWorker
smartproxy
smartstate
).tap do |roles|
roles << 'ems_inventory' unless Settings.prototype.ems_vmware.update_driven_refresh
roles << 'ems_inventory' unless Settings.ems_refresh.vmwarews.streaming_refresh
end
}

Expand Down
2 changes: 1 addition & 1 deletion app/models/miq_vim_broker_worker/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def reset_broker_update_sleep_interval
end

def has_ems_inventory_role?
@active_roles.include?("ems_inventory") && !Settings.prototype.ems_vmware.update_driven_refresh
@active_roles.include?("ems_inventory") && !Settings.ems_refresh.vmwarews.streaming_refresh
end

def reset_broker_update_notification
Expand Down
5 changes: 2 additions & 3 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
:power:
:critical:
:ems_refresh:
:vmwarews:
:streaming_refresh: true
:vmware_cloud:
:inventory_object_refresh: false
:get_public_images: false
Expand All @@ -27,9 +29,6 @@
:user:
#:log:
# :level_vim: warn
:prototype:
:ems_vmware:
:update_driven_refresh: false
:workers:
:worker_base:
:event_catcher:
Expand Down
16 changes: 8 additions & 8 deletions spec/models/miq_ems_refresh_core_worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
end

context ".has_required_role?" do
context "with update_driven_refresh" do
context "with streaming_refresh" do
before do
stub_settings_merge(
:prototype => {
:ems_vmware => {
:update_driven_refresh => true
:ems_refresh => {
:vmwarews => {
:streaming_refresh => true
}
}
)
Expand All @@ -23,12 +23,12 @@
expect(described_class.has_required_role?).to be_falsy
end
end
context "without update_driven_refresh" do
context "without streaming_refresh" do
before do
stub_settings_merge(
:prototype => {
:ems_vmware => {
:update_driven_refresh => false
:ems_refresh => {
:vmwarews => {
:streaming_refresh => false
}
}
)
Expand Down
4 changes: 2 additions & 2 deletions spec/models/miq_vim_broker_worker/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@
expect(MiqVimBroker.cacheScope).to eq(:cache_scope_core)
end

it "with ems_inventory role using update_driven_refresh" do
stub_settings(:prototype => {:ems_vmware => {:update_driven_refresh => true}})
it "with ems_inventory role using streaming_refresh" do
stub_settings(:ems_refresh => {:vmwarews => {:streaming_refresh => true}})
@vim_broker_worker.instance_variable_set(:@active_roles, ['ems_inventory'])
expect(MiqVimBroker).to receive(:new).with(:server).once
@vim_broker_worker.create_miq_vim_broker_server
Expand Down
14 changes: 7 additions & 7 deletions spec/models/miq_vim_broker_worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
expect(described_class.emses_to_monitor).to match_array @zone.ext_management_systems
end

context "update_driven_refresh" do
context "streaming_refresh" do
before do
stub_settings_merge(
:prototype => {
:ems_vmware => {
:update_driven_refresh => true
:ems_refresh => {
:vmwarews => {
:streaming_refresh => true
}
}
)
Expand All @@ -27,9 +27,9 @@
context "standard refresh" do
before do
stub_settings_merge(
:prototype => {
:ems_vmware => {
:update_driven_refresh => false
:ems_refresh => {
:vmwarews => {
:streaming_refresh => false
}
}
)
Expand Down

0 comments on commit 39ce0ce

Please sign in to comment.