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

Conversation

tinaafitz
Copy link
Member

@tinaafitz tinaafitz commented Jan 8, 2018

Prevent error in check_quota(:active_provisions) for Service MiqRequests with invalid service_templates.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1531914

We recently changed the active_provision code to calculate quota values for Service requests by looking at the request service_template.service_resource information.
The customer supplied data showed Service requests miq_tasks queued to a zone but never dispatched, it appears the Zone or automate role for the zone was disabled. This made the Service requests look like they were active, but were not being processed. Then the service_template for which the Service request was created was deleted causing the Service request to have an invalid service_template relationship.

Although the issue impacts any calls to the check_quota(:active_provisions) method, the customer encountered it in the request.check_quota(:active_provisions) call here:
RedHat Automate domain method:
/Infrastructure/VM/Provisioning/Placement/vmware_best_fit_with_scope
Since the vmware_best_fit_with_scope method is used during VM Provisioning, all provisions would fail if the active_quota calculations encountered a single Service MiqRequest with an invalid service_template, even if Quota is not being used.

@tinaafitz
Copy link
Member Author

@miq_bot add_label bug, provisioning, services, gaprindashvili/yes

@miq-bot
Copy link
Member

miq-bot commented Jan 8, 2018

Checked commit tinaafitz@0d6e974 with ruby 2.3.3, rubocop 0.47.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. 🍪

@tinaafitz
Copy link
Member Author

@miq-bot assign @gmcculloug

@gmcculloug
Copy link
Member

@tinaafitz In the description It makes more sense to focus on the call to check_quota(:active_provisions) instead of the locations that it is being called from. The issue would impact any call to that method and is not directly related to where it is being called from. It does makes sense to reference where the call was as it explains why the provision task raised the error in this case, but again the best-fit method is not the main cause of the issue.

Also, some more background on the error condition (Service MiqRequest with an invalid service_template) would be useful for someone viewing this PR in the future.

By which I mean, we determined that tasks were queued to a zone but never dispatched, it appears the Zone or automate role for the zone was disabled. This made the requests look like they were active, but were not being processed. Then the service_template for which the request was created was deleted causing the request to have an invalid service_template relationship.

@tinaafitz tinaafitz changed the title Quota fix for invalid service_template. Fix check_quota(:active_provisions) for Service MiqRequest invalid service_template. Jan 9, 2018
@tinaafitz
Copy link
Member Author

@gmcculloug Thank you for the feedback. I've updated the PR description with more detail. Please let me know if there's anything else you'd like me change.


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.

@gmcculloug gmcculloug merged commit 8aa881f into ManageIQ:master Jan 9, 2018
@gmcculloug gmcculloug added this to the Sprint 77 Ending Jan 15, 2018 milestone Jan 9, 2018
simaishi pushed a commit that referenced this pull request Jan 10, 2018
…_fix

Fix check_quota(:active_provisions) for Service MiqRequest invalid service_template.
(cherry picked from commit 8aa881f)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1533217
@simaishi
Copy link
Contributor

Gaprindashvili backport details:

$ git log -1
commit 9b58a4a4dc2a0bc90849c432584e0a22b2d07513
Author: Greg McCullough <gmccullo@redhat.com>
Date:   Tue Jan 9 15:30:37 2018 -0500

    Merge pull request #16769 from tinaafitz/quota_mixin_service_template_fix
    
    Fix check_quota(:active_provisions) for Service MiqRequest invalid service_template.
    (cherry picked from commit 8aa881f53bfa3ae2517921bbd061d82d01ccd600)
    
    Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1533217

simaishi pushed a commit that referenced this pull request Jan 15, 2018
…_fix

Fix check_quota(:active_provisions) for Service MiqRequest invalid service_template.
(cherry picked from commit 8aa881f)

https://bugzilla.redhat.com/show_bug.cgi?id=1534589
@simaishi
Copy link
Contributor

Fine backport details:

$ git log -1
commit 7de622587cc1a162178b6ccf9d78f2188522d3f9
Author: Greg McCullough <gmccullo@redhat.com>
Date:   Tue Jan 9 15:30:37 2018 -0500

    Merge pull request #16769 from tinaafitz/quota_mixin_service_template_fix
    
    Fix check_quota(:active_provisions) for Service MiqRequest invalid service_template.
    (cherry picked from commit 8aa881f53bfa3ae2517921bbd061d82d01ccd600)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1534589

d-m-u pushed a commit to d-m-u/manageiq that referenced this pull request Jun 6, 2018
…template_fix

Fix check_quota(:active_provisions) for Service MiqRequest invalid service_template.
(cherry picked from commit 8aa881f)

https://bugzilla.redhat.com/show_bug.cgi?id=1534589
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.

4 participants