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 check_quota(:active_provisions) for Service MiqRequest invalid service_template. #16769

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/models/mixins/miq_provision_quota_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ def vm_quota_values(pr, result)
end

def service_quota_values(request, result)
return unless request.service_template
request.service_template.service_resources.each do |sr|
if request.service_template.service_type == 'composite'
bundle_quota_values(sr, result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ def create_service_bundle(user, items, options = {})
context "active_provisions_by_tenant," do
let(:quota_method) { :active_provisions_by_tenant }
it_behaves_like "check_quota"

it "invalid service_template does not raise error" do
requests = load_queue
requests.first.update_attributes(:service_template => nil)
Copy link
Member

Choose a reason for hiding this comment

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

Does load_queue only queue ServiceTemplateProvisionRequest instances? In other words, are you sure this first request will by a ServiceTemplateProvisionRequest and therefore expect to have a service_template relationship?

Copy link
Member Author

Choose a reason for hiding this comment

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

@gmcculloug Yes, I am sure the first request will be a ServiceTemplateProvisionRequest since load_queue only queues ServiceTemplateProvisionRequest instances.

expect { request.check_quota(quota_method) }.not_to raise_error
end
end

context "active_provisions_by_group," do
Expand Down