[WIP] Move VirtualMachineTemplate handling to OpenShift#297
Open
agrare wants to merge 1 commit intoManageIQ:masterfrom
Open
[WIP] Move VirtualMachineTemplate handling to OpenShift#297agrare wants to merge 1 commit intoManageIQ:masterfrom
agrare wants to merge 1 commit intoManageIQ:masterfrom
Conversation
agrare
commented
Jan 23, 2026
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 |
Member
Author
There was a problem hiding this comment.
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
290c639 to
a004661
Compare
Member
Author
|
@miq-bot cross-repo-test ManageIQ/manageiq-providers-kubevirt#320 |
miq-bot
pushed a commit
to ManageIQ/manageiq-cross_repo-tests
that referenced
this pull request
Jan 26, 2026
From Pull Request: ManageIQ/manageiq-providers-openshift#297
Member
|
Checked commit agrare@a004661 with ruby 3.1.7, rubocop 1.56.3, haml-lint 0.64.0, and yamllint 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
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: