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

[WIP] Prevent a vm or template being its own parent #23302

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

agrare
Copy link
Member

@agrare agrare commented Jan 10, 2025

Prevent a vm or template from being assigned as its own parent, preventing the ancestry "cannot be a descendant of itself" exception

Fixes ManageIQ/manageiq-providers-openstack#862

@agrare agrare force-pushed the fix_genealogy_self_parent branch from 5938445 to 0528763 Compare January 10, 2025 15:56
@agrare
Copy link
Member Author

agrare commented Jan 10, 2025

@miq-bot cross-repo-test /providers

miq-bot pushed a commit to ManageIQ/manageiq-cross_repo-tests that referenced this pull request Jan 10, 2025
@agrare agrare force-pushed the fix_genealogy_self_parent branch from 0528763 to 01ece9e Compare January 10, 2025 19:52
@Dhamo1107
Copy link

Dhamo1107 commented Jan 11, 2025

Hi @agrare, I used the changes you committed in this PR, but again i got the same error. What is the work around for this to fix this issue

ERROR -- evm: MIQ(ManageIQ::Providers::Openstack::CloudManager::Refresher#refresh) EMS: [Redhat Openstack DC], id: [1000000000007] Refresh failed
Jan 11 01:36:31 cmp-app evm[30063]: ERROR -- evm: [ActiveRecord::RecordInvalid]: Validation failed: ManageIQ::providers::openstack::cloudmanager::template cannot be a descendant of itself.  Method:[block (2 levels) in <class:LogProxy>]
Jan 11 01:36:31 cmp-app evm[30063]: ERROR -- evm: /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/validations.rb:80:in `raise_validation_error'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/validations.rb:53:in `save!'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/transactions.rb:302:in `block in save!'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/transactions.rb:354:in `block in with_transaction_returning_status'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/connection_adapters/abstract/database_statements.rb:318:in `transaction'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/transactions.rb:350:in `with_transaction_returning_status'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/transactions.rb:302:in `save!'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/suppressor.rb:48:in `save!'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/persistence.rb:639:in `block in update!'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/transactions.rb:354:in `block in with_transaction_returning_status'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/connection_adapters/abstract/database_statements.rb:318:in `transaction'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/transactions.rb:350:in `with_transaction_returning_status'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/persistence.rb:637:in `update!'
                                    /var/www/miq/vmdb/app/models/manageiq/providers/inventory/persister/builder/cloud_manager.rb:211:in `block (3 levels) in vm_and_miq_template_ancestry_save_block'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/relation/batches.rb:71:in `block (2 levels) in find_each'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/relation/batches.rb:71:in `each'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/relation/batches.rb:71:in `block in find_each'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/relation/batches.rb:138:in `block in find_in_batches'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/relation/batches.rb:245:in `block in in_batches'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/relation/batches.rb:229:in `loop'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/relation/batches.rb:229:in `in_batches'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/relation/batches.rb:137:in `find_in_batches'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/relation/batches.rb:70:in `find_each'
                                    /var/www/miq/vmdb/app/models/manageiq/providers/inventory/persister/builder/cloud_manager.rb:210:in `block (2 levels) in vm_and_miq_template_ancestry_save_block'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `block in transaction'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/connection_adapters/abstract/transaction.rb:319:in `block in within_new_transaction'
                                    /opt/manageiq/manageiq-gemset/gems/activesupport-6.1.7.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:26:in `block (2 levels) in synchronize'
                                    /opt/manageiq/manageiq-gemset/gems/activesupport-6.1.7.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `handle_interrupt'
                                    /opt/manageiq/manageiq-gemset/gems/activesupport-6.1.7.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:25:in `block in synchronize'
                                    /opt/manageiq/manageiq-gemset/gems/activesupport-6.1.7.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `handle_interrupt'
                                    /opt/manageiq/manageiq-gemset/gems/activesupport-6.1.7.4/lib/active_support/concurrency/load_interlock_aware_monitor.rb:21:in `synchronize'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/connection_adapters/abstract/transaction.rb:317:in `within_new_transaction'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/connection_adapters/abstract/database_statements.rb:320:in `transaction'
                                    /opt/manageiq/manageiq-gemset/gems/activerecord-6.1.7.4/lib/active_record/transactions.rb:209:in `transaction'
                                    /var/www/miq/vmdb/app/models/manageiq/providers/inventory/persister/builder/cloud_manager.rb:205:in `block in vm_and_miq_template_ancestry_save_block'
                                    /opt/manageiq/manageiq-gemset/gems/inventory_refresh-2.0.0/lib/inventory_refresh/save_collection/base.rb:23:in `save_inventory_object_inventory'
                                    /opt/manageiq/manageiq-gemset/gems/inventory_refresh-2.0.0/lib/inventory_refresh/save_collection/topological_sort.rb:29:in `block (2 levels) in save_collections'
                                    /opt/manageiq/manageiq-gemset/gems/inventory_refresh-2.0.0/lib/inventory_refresh/save_collection/topological_sort.rb:28:in `each'
                                    /opt/manageiq/manageiq-gemset/gems/inventory_refresh-2.0.0/lib/inventory_refresh/save_collection/topological_sort.rb:28:in `block in save_collections'
                                    /opt/manageiq/manageiq-gemset/gems/inventory_refresh-2.0.0/lib/inventory_refresh/save_collection/topological_sort.rb:26:in `each'
                                    /opt/manageiq/manageiq-gemset/gems/inventory_refresh-2.0.0/lib/inventory_refresh/save_collection/topological_sort.rb:26:in `each_with_index'
                                    /opt/manageiq/manageiq-gemset/gems/inventory_refresh-2.0.0/lib/inventory_refresh/save_collection/topological_sort.rb:26:in `save_collections'
                                    /opt/manageiq/manageiq-gemset/gems/inventory_refresh-2.0.0/lib/inventory_refresh/save_inventory.rb:20:in `save_inventory'
                                    /var/www/miq/vmdb/app/models/manageiq/providers/base_manager/refresher.rb:144:in `save_inventory'
                                    /opt/manageiq/manageiq-gemset/bundler/gems/manageiq-providers-openstack-c18e073b6552/app/models/manageiq/providers/openstack/cloud_manager/refresher.rb:4:in `save_inventory'
                                    /var/www/miq/vmdb/app/models/manageiq/providers/base_manager/refresher.rb:100:in `block in refresh_targets_for_ems'
                                    /opt/manageiq/manageiq-gemset/gems/more_core_extensions-4.4.0/lib/more_core_extensions/core_ext/benchmark/realtime_store.rb:20:in `realtime_store'
                                    /opt/manageiq/manageiq-gemset/gems/more_core_extensions-4.4.0/lib/more_core_extensions/core_ext/benchmark/realtime_store.rb:56:in `realtime_block'
                                    /var/www/miq/vmdb/app/models/manageiq/providers/base_manager/refresher.rb:100:in `refresh_targets_for_ems'
                                    /var/www/miq/vmdb/app/models/manageiq/providers/base_manager/refresher.rb:41:in `block (2 levels) in refresh'
                                    /opt/manageiq/manageiq-gemset/gems/more_core_extensions-4.4.0/lib/more_core_extensions/core_ext/benchmark/realtime_store.rb:20:in `realtime_store'
                                    /opt/manageiq/manageiq-gemset/gems/more_core_extensions-4.4.0/lib/more_core_extensions/core_ext/benchmark/realtime_store.rb:62:in `realtime_block'
                                    /var/www/miq/vmdb/app/models/manageiq/providers/base_manager/refresher.rb:41:in `block in refresh'
                                    /var/www/miq/vmdb/app/models/manageiq/providers/base_manager/refresher.rb:31:in `each'
                                    /var/www/miq/vmdb/app/models/manageiq/providers/base_manager/refresher.rb:31:in `refresh'
                                    /var/www/miq/vmdb/app/models/manageiq/providers/base_manager/refresher.rb:11:in `refresh'
                                    /var/www/miq/vmdb/app/models/ems_refresh.rb:74:in `block in refresh'
                                    /var/www/miq/vmdb/app/models/ems_refresh.rb:73:in `each'
                                    /var/www/miq/vmdb/app/models/ems_refresh.rb:73:in `refresh'
                                    /var/www/miq/vmdb/app/models/miq_queue.rb:517:in `block in dispatch_method'
                                    /opt/manageiq/manageiq-gemset/gems/timeout-0.3.2/lib/timeout.rb:189:in `block in timeout'
                                    /opt/manageiq/manageiq-gemset/gems/timeout-0.3.2/lib/timeout.rb:36:in `block in catch'
                                    /opt/manageiq/manageiq-gemset/gems/timeout-0.3.2/lib/timeout.rb:36:in `catch'
                                    /opt/manageiq/manageiq-gemset/gems/timeout-0.3.2/lib/timeout.rb:36:in `catch'
                                    /opt/manageiq/manageiq-gemset/gems/timeout-0.3.2/lib/timeout.rb:198:in `timeout'
                                    /var/www/miq/vmdb/app/models/miq_queue.rb:515:in `dispatch_method'
                                    /var/www/miq/vmdb/app/models/miq_queue.rb:484:in `block in deliver'
                                    /var/www/miq/vmdb/app/models/user.rb:382:in `with_user_group'
                                    /var/www/miq/vmdb/app/mo...
Jan 11 01:36:31 cmp-app evm[30063]: ERROR -- evm: MIQ(ManageIQ::Providers::Openstack::CloudManager::Refresher#refresh) EMS: [Redhat Openstack DC], id: [1000000000007] Unable to perform refresh for the following targets:
Jan 11 01:36:31 cmp-app evm[30063]: ERROR -- evm: MIQ(ManageIQ::Providers::Openstack::CloudManager::Refresher#refresh)  --- ManageIQ::Providers::Openstack::CloudManager [Redhat Openstack DC] id [1000000000007]
Jan 11 01:36:31 cmp-app evm[30063]:  INFO -- evm: MIQ(ManageIQ::Providers::Openstack::CloudManager::Refresher#refresh) Refreshing all targets...Complete
Jan 11 01:36:31 cmp-app evm[30063]: ERROR -- evm: MIQ(MiqQueue#deliver) Message id: [1000000021825], Error: [Validation failed: ManageIQ::providers::openstack::cloudmanager::template cannot be a descendant of itself.]
Jan 11 01:36:31 cmp-app evm[30063]: ERROR -- evm: [ManageIQ::Providers::BaseManager::Refresher::PartialRefreshError]: Validation failed: ManageIQ::providers::openstack::cloudmanager::template cannot be a descendant of itself.  Method:[block (2 levels) in <class:LogProxy>]
Jan 11 01:36:31 cmp-app evm[30063]: ERROR -- evm: /var/www/miq/vmdb/app/models/manageiq/providers/base_manager/refresher.rb:68:in `refresh'
                                    /var/www/miq/vmdb/app/models/manageiq/providers/base_manager/refresher.rb:11:in `refresh'
                                    /var/www/miq/vmdb/app/models/ems_refresh.rb:74:in `block in refresh'
                                    /var/www/miq/vmdb/app/models/ems_refresh.rb:73:in `each'
                                    /var/www/miq/vmdb/app/models/ems_refresh.rb:73:in `refresh'
                                    /var/www/miq/vmdb/app/models/miq_queue.rb:517:in `block in dispatch_method'
                                    /opt/manageiq/manageiq-gemset/gems/timeout-0.3.2/lib/timeout.rb:189:in `block in timeout'
                                    /opt/manageiq/manageiq-gemset/gems/timeout-0.3.2/lib/timeout.rb:36:in `block in catch'
                                    /opt/manageiq/manageiq-gemset/gems/timeout-0.3.2/lib/timeout.rb:36:in `catch'
                                    /opt/manageiq/manageiq-gemset/gems/timeout-0.3.2/lib/timeout.rb:36:in `catch'
                                    /opt/manageiq/manageiq-gemset/gems/timeout-0.3.2/lib/timeout.rb:198:in `timeout'
                                    /var/www/miq/vmdb/app/models/miq_queue.rb:515:in `dispatch_method'
                                    /var/www/miq/vmdb/app/models/miq_queue.rb:484:in `block in deliver'
                                    /var/www/miq/vmdb/app/models/user.rb:382:in `with_user_group'
                                    /var/www/miq/vmdb/app/models/miq_queue.rb:484:in `deliver'
                                    /var/www/miq/vmdb/app/models/miq_queue_worker_base/runner.rb:98:in `deliver_queue_message'
                                    /var/www/miq/vmdb/app/models/miq_queue_worker_base/runner.rb:124:in `deliver_message'
                                    /var/www/miq/vmdb/app/models/miq_queue_worker_base/runner.rb:146:in `block in do_work'
                                    /var/www/miq/vmdb/app/models/miq_queue_worker_base/runner.rb:142:in `loop'
                                    /var/www/miq/vmdb/app/models/miq_queue_worker_base/runner.rb:142:in `do_work'
                                    /var/www/miq/vmdb/app/models/miq_worker/runner.rb:295:in `block in do_work_loop'
                                    /var/www/miq/vmdb/app/models/miq_worker/runner.rb:292:in `loop'
                                    /var/www/miq/vmdb/app/models/miq_worker/runner.rb:292:in `do_work_loop'
                                    /var/www/miq/vmdb/app/models/miq_worker/runner.rb:142:in `run'
                                    /var/www/miq/vmdb/app/models/miq_worker/runner.rb:100:in `start_rails_worker'
                                    /var/www/miq/vmdb/app/models/miq_worker/runner.rb:95:in `start'
                                    lib/workers/bin/run_single_worker.rb:128:in <main>

@agrare
Copy link
Member Author

agrare commented Jan 11, 2025

@Dhamo1107 thank you for testing! It sounds like we need some more logging / diagnostics to try to find which image or images have this issue. I'll add some more logging to this save block and the openstack parser to try to help find the issue.

@Dhamo1107
Copy link

Okay @agrare

@Dhamo1107
Copy link

Prevent a vm or template from being assigned as its own parent, preventing the ancestry "cannot be a descendant of itself" exception

Fixes ManageIQ/manageiq-providers-openstack#862

How to fix this issue @agrare

@agrare
Copy link
Member Author

agrare commented Jan 13, 2025

I'm working on it @Dhamo1107 😉

Based on the openstack parser it isn't clear to me how a template could be assigned itself as a genealogy parent because it is only looking at the vms collection so it couldn't even find itself in the database.

@Dhamo1107
Copy link

Thank you @agrare,

Any work around for this, because not able to do refresh relationship for that provider

@agrare
Copy link
Member Author

agrare commented Jan 13, 2025

@agrare
Copy link
Member Author

agrare commented Jan 13, 2025

Okay @Dhamo1107 can you try testing out the latest updates in this PR, un-comment the collection in the openstack persister if you commented it out, and try applying the changes here https://github.com/ManageIQ/manageiq-providers-openstack/pull/899/files

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.

Validation failed: ManageIQ::providers::openstack::cloudmanager::template cannot be a descendant of itself.
3 participants