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

Fix missing 'storages' association on Datacenter #23252

Conversation

agrare
Copy link
Member

@agrare agrare commented Nov 1, 2024

When provisioning a Vm as a user that belongs to a group with a belongs_to filter applying Rbac on storages fails due to a missing virtual_has_many on the Datacenter base class.

#<ActiveRecord::AssociationNotFoundError: Association named 'storages' was not found on ManageIQ::Providers::Vmware::InfraManager::Folder; perhaps you misspelled it?>
gems/activerecord-6.1.7.8/lib/active_record/associations.rb:313:in `association'
gems/activerecord-virtual_attributes-6.1.2/lib/active_record/virtual_attributes/virtual_fields.rb:169:in `block in grouped_records'
gems/activerecord-virtual_attributes-6.1.2/lib/active_record/virtual_attributes/virtual_fields.rb:157:in `each'
gems/activerecord-virtual_attributes-6.1.2/lib/active_record/virtual_attributes/virtual_fields.rb:157:in `grouped_records'
gems/activerecord-virtual_attributes-6.1.2/lib/active_record/virtual_attributes/virtual_fields.rb:148:in                     `preloaders_for_one'
gems/activerecord-6.1.7.8/lib/active_record/associations/preloader.rb:110:in `preloaders_on'
gems/activerecord-6.1.7.8/lib/active_record/associations/preloader.rb:94:in `block in preload'
gems/activerecord-6.1.7.8/lib/active_record/associations/preloader.rb:93:in `each'
gems/activerecord-6.1.7.8/lib/active_record/associations/preloader.rb:93:in `flat_map'
gems/activerecord-6.1.7.8/lib/active_record/associations/preloader.rb:93:in `preload'
/var/www/miq/vmdb/lib/miq_preloader.rb:26:in `preload'
/var/www/miq/vmdb/lib/miq_preloader.rb:48:in `block in preload_and_map'
<internal:kernel>:90:in `tap'
/var/www/miq/vmdb/lib/miq_preloader.rb:48:in `preload_and_map'
/var/www/miq/vmdb/lib/rbac/filterer.rb:918:in `get_belongsto_matches_for_storage'
/var/www/miq/vmdb/lib/rbac/filterer.rb:846:in `get_belongsto_matches'
/var/www/miq/vmdb/lib/rbac/filterer.rb:594:in `get_belongsto_filter_object_ids'
/var/www/miq/vmdb/lib/rbac/filterer.rb:532:in `calc_filtered_ids'
/var/www/miq/vmdb/lib/rbac/filterer.rb:724:in `scope_targets'
/var/www/miq/vmdb/lib/rbac/filterer.rb:297:in `search'
/var/www/miq/vmdb/lib/rbac/filterer.rb:177:in `search'
/var/www/miq/vmdb/lib/rbac.rb:3:in `search'
/var/www/miq/vmdb/lib/rbac/filterer.rb:447:in `filtered'
/var/www/miq/vmdb/lib/rbac/filterer.rb:181:in `filtered'
/var/www/miq/vmdb/lib/rbac.rb:11:in `filtered'
/var/www/miq/vmdb/app/models/miq_search.rb:43:in `filtered'
/var/www/miq/vmdb/app/models/miq_request_workflow.rb:840:in `process_filter'
/var/www/miq/vmdb/app/models/miq_request_workflow.rb:1109:in `allowed_storages'
/var/www/miq/vmdb/app/models/miq_request_workflow.rb:293:in `get_field'
/var/www/miq/vmdb/app/models/miq_request_workflow.rb:280:in `block in get_all_fields'
/var/www/miq/vmdb/app/models/miq_request_workflow.rb:280:in `each_key'
/var/www/miq/vmdb/app/models/miq_request_workflow.rb:280:in `get_all_fields'
/var/www/miq/vmdb/app/models/miq_request_workflow.rb:272:in `get_dialog'
/var/www/miq/vmdb/app/models/miq_request_workflow.rb:264:in `block in get_all_dialogs'
/var/www/miq/vmdb/app/models/miq_request_workflow.rb:264:in `each_key'
/var/www/miq/vmdb/app/models/miq_request_workflow.rb:264:in `get_all_dialogs'
/var/www/miq/vmdb/app/models/miq_provision_virt_workflow.rb:84:in `refresh_field_values'

@jrafanie
Copy link
Member

jrafanie commented Nov 1, 2024

Let me know if you're able to write a test for this. 😉

When provisioning a Vm as a user that belongs to a group with a
belongs_to filter applying Rbac on storages fails due to a missing
virtual_has_many on the Datacenter base class.
@agrare agrare force-pushed the fix_association_named_storages_not_found_on_datacenter branch from 05ccbc7 to 7eb283d Compare November 1, 2024 16:48
@agrare
Copy link
Member Author

agrare commented Nov 1, 2024

Let me know if you're able to write a test for this. 😉

Ha yeah working on it, I thought I had it down but it doesn't fail without the change to EmsFolder so it isn't going down the same exact path. I'll push up what I have now

Copy link
Member

@jrafanie jrafanie left a comment

Choose a reason for hiding this comment

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

sorry, didn't see the test pushed... LGTM. It's a contrived example but demonstrates how the filters are really an "allowed" list and anything not in the list is "not allowed".

@jrafanie jrafanie self-assigned this Nov 1, 2024
@jrafanie jrafanie merged commit eccb749 into ManageIQ:master Nov 1, 2024
12 checks passed
@agrare agrare deleted the fix_association_named_storages_not_found_on_datacenter branch November 2, 2024 02:31
@agrare
Copy link
Member Author

agrare commented Nov 4, 2024

I thought I had it down but it doesn't fail without the change to EmsFolder so it isn't going down the same exact path

Fixed the issue described in ☝️ here: #23256

@Fryguy
Copy link
Member

Fryguy commented Nov 4, 2024

Backported to radjabov via merge of master into radjabov

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.

3 participants