Skip to content

Commit

Permalink
Debug updates
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Apr 5, 2024
1 parent 451cae7 commit c37a3da
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ class ManageIQ::Providers::Vmware::InfraManager::Inventory::Collector
include PropertyCollector
include Vmdb::Logging

def initialize(ems)
def initialize(ems, refresher_options = {})
@ems = ems
@exit_requested = false
@cache = cache_klass.new
@saver = saver_klass.new
@vim_thread = nil

@debug_updates = refresher_options.debug_updates || false
@debug_updates_tempdir = Dir.mktmpdir("#{self.class.name}-#{ems.id}") if debug_updates
end

def refresh
Expand Down Expand Up @@ -41,7 +44,7 @@ def restart(join_timeout = 2.minutes)

private

attr_reader :ems, :saver
attr_reader :ems, :saver, :debug_updates
attr_accessor :exit_requested, :vim_thread, :last_full_refresh

def vim_collector_thread
Expand Down Expand Up @@ -125,6 +128,8 @@ def monitor_updates(vim, property_filter, version)
update_set = wait_for_updates(vim, version)
break if update_set.nil?

dump_update_set(update_set) if debug_updates

version = update_set.version
updated_objects.concat(process_update_set(property_filter, update_set))
break unless update_set.truncated
Expand Down Expand Up @@ -463,6 +468,11 @@ def log_object_update(object_update)
end
end

def dump_update_set(update_set)
version = update_set.version
File.write("#{@debug_updates_tempdir}/#{update_set.version}.yml", update_set.to_yaml)
end

def full_refresh_needed?
(Time.now.utc - last_full_refresh) > full_refresh_interval
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ def deliver_queue_message(msg)

attr_accessor :ems, :collector

def refresher_options
Settings.ems_refresh.vmwarews
end

def start_inventory_collector
self.collector = ManageIQ::Providers::Vmware::InfraManager::Inventory::Collector.new(ems)
self.collector = ManageIQ::Providers::Vmware::InfraManager::Inventory::Collector.new(ems, refresher_options)
collector.start
_log.info("Started inventory collector")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def refresh
raise NotImplementedError, "not implemented in production mode" if Rails.env.production?

ems_by_ems_id.each do |_ems_id, ems|
collector = ems.class::Inventory::Collector.new(ems)
collector = ems.class::Inventory::Collector.new(ems, refresher_options)
collector.refresh
end
end
Expand Down
1 change: 1 addition & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
:vmwarews:
:refresh_interval: 24.hours
:update_poll_interval: 1.second
:debug_updates: true
:http_proxy:
:vmware_cloud:
:host:
Expand Down

0 comments on commit c37a3da

Please sign in to comment.