Skip to content

[WIP] Move VirtualMachineTemplate handling to OpenShift#297

Open
agrare wants to merge 1 commit intoManageIQ:masterfrom
agrare:move_openshift_infra_templates
Open

[WIP] Move VirtualMachineTemplate handling to OpenShift#297
agrare wants to merge 1 commit intoManageIQ:masterfrom
agrare:move_openshift_infra_templates

Conversation

@agrare
Copy link
Member

@agrare agrare commented Jan 23, 2026

@agrare agrare requested a review from Fryguy as a code owner January 23, 2026 19:09
Comment on lines +21 to +76

#
# Performs a full refresh.
#
def full_refresh
# Create and populate the collector, persister and parser
# and parse inventories
inventory = provider_class::Inventory.build(manager, nil)
collector = inventory.collector
persister = inventory.parse

# execute persist:
persister&.persist!

# Update the memory:
memory.add_list_version(:nodes, collector.nodes.resourceVersion)
memory.add_list_version(:vms, collector.vms.resourceVersion)
memory.add_list_version(:vm_instances, collector.vm_instances.resourceVersion)
memory.add_list_version(:templates, collector.templates.resourceVersion)
memory.add_list_version(:instance_types, collector.instance_types.resourceVersion)

manager.update(:last_refresh_error => nil, :last_refresh_date => Time.now.utc)
rescue StandardError => error
_log.error('Full refresh failed.')
_log.log_backtrace(error)
manager.update(:last_refresh_error => error.to_s, :last_refresh_date => Time.now.utc)
end

#
# Start watches
#
def start_watches
# This flag will be used to tell the threads to get out of their loops:
@finish = Concurrent::AtomicBoolean.new(false)

# Create the watches:
@watches = []
@watches << @manager.kubeclient.watch_nodes(:resource_version => memory.get_list_version(:nodes))
@watches << @manager.kubeclient("kubevirt.io/v1").watch_virtual_machines(:resource_version => memory.get_list_version(:vms))
@watches << @manager.kubeclient("kubevirt.io/v1").watch_virtual_machine_instances(:resource_version => memory.get_list_version(:vm_instances))
@watches << @manager.kubeclient("template.openshift.io/v1").watch_templates(:resource_version => memory.get_list_version(:templates))
@watches << @manager.kubeclient("instancetype.kubevirt.io/v1beta1").watch_virtual_machine_cluster_instancetypes(:resource_version => memory.get_list_version(:instance_types))

# Create the threads that run the watches and put the notices in the queue:
@watchers = []
@watches.each do |watch|
thread = Thread.new do
until @finish.value
watch.each do |notice|
@queue.push(notice)
end
end
end
@watchers << thread
end
end
Copy link
Member Author

Choose a reason for hiding this comment

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

TODO if we move the list of watches out into a method that could be overridden we don't have to override these entire methods

@agrare agrare force-pushed the move_openshift_infra_templates branch from 290c639 to a004661 Compare January 26, 2026 17:31
@agrare
Copy link
Member Author

agrare commented Jan 26, 2026

@miq-bot cross-repo-test ManageIQ/manageiq-providers-kubevirt#320

@miq-bot
Copy link
Member

miq-bot commented Jan 28, 2026

Checked commit agrare@a004661 with ruby 3.1.7, rubocop 1.56.3, haml-lint 0.64.0, and yamllint
8 files checked, 3 offenses detected

app/models/manageiq/providers/openshift/infra_manager/refresh_worker/runner.rb

app/models/manageiq/providers/openshift/inventory/collector/infra_manager/full_refresh.rb

app/models/manageiq/providers/openshift/inventory/persister/infra_manager.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants