Skip to content

Commit

Permalink
Merge pull request #17158 from tinaafitz/fix_quota_invalid_template
Browse files Browse the repository at this point in the history
Fix active_provision quota check for infra VM request with invalid vm_template.
(cherry picked from commit 9002fc7)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1559550
  • Loading branch information
gmcculloug authored and simaishi committed Mar 22, 2018
1 parent b7feadd commit f6e9221
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/models/mixins/miq_provision_quota_mixin.rb
Original file line number Diff line number Diff line change
@@ -282,6 +282,10 @@ def quota_find_active_prov_request(_options)
:status => 'Ok',
:process => true
).where.not(:id => id)
.where(%{source_type IS NULL OR
(source_type = 'VmOrTemplate' AND source_id IN (SELECT id FROM vms)) OR
(source_type = 'ServiceTemplate' AND source_id IN (SELECT id FROM service_templates))
})
end

def vm_quota_values(pr, result)
6 changes: 6 additions & 0 deletions spec/models/miq_provision_request_spec.rb
Original file line number Diff line number Diff line change
@@ -201,6 +201,12 @@ def create_request(user, vm_template, prov_options)
{:count => 12, :memory => 8_589_938_688, :cpu => 32, :storage => 44.gigabytes}
end
it_behaves_like "check_quota"

it "invalid vm_template does not raise error" do
create_requests
MiqRequest.first.update_attributes(:vm_template => nil)
expect { request.check_quota(quota_method) }.not_to raise_error
end
end

context "infra," do

0 comments on commit f6e9221

Please sign in to comment.