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

Fail with descriptive message when no EMS #15807

Merged

Conversation

masayag
Copy link
Contributor

@masayag masayag commented Aug 14, 2017

When no EMS is associated with a VM or template, the provision request
fails with a non-descriptive message. Such case might happen when the VM
or template were removed from the provider side, but still exist as
archived on vmdb. The purpose of the PR is to provide a clear failure
message when there is no EMS.

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

@masayag
Copy link
Contributor Author

masayag commented Aug 14, 2017

@gmcculloug please review

@masayag
Copy link
Contributor Author

masayag commented Aug 14, 2017

@@ -29,6 +29,10 @@ def self.request_task_class_from(attribs)
vm_or_template = VmOrTemplate.find_by(:id => source_id)
raise MiqException::MiqProvisionError, "Unable to find source Template/Vm with id [#{source_id}]" if vm_or_template.nil?

if vm_or_template.ext_management_system.nil?
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I would like this better if we pulled both checks (line 30 and line 32) into a single method. Since we check for both a template and with this change an ems it makes sense to consolidate the code that in either case can raise the same exception.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've extracted it into a method to retrieve the vm/template or raise an exception if failed to.

@masayag masayag force-pushed the fail_when_vm_or_template_has_no_ems branch from 7e599b6 to a0dcf2a Compare August 15, 2017 09:31

via = MiqRequestMixin.get_option(:provision_type, nil, attribs['options'])
vm_or_template.ext_management_system.class.provision_class(via)
end

def self.fetch_vm_or_template_for_provision!(source_id)
Copy link
Member

Choose a reason for hiding this comment

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

Suggest renaming to self.source_vm_or_template!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

When no EMS is associated with a VM or template, the provision request
fails with a non-descriptive message. Such case might happen when the VM
or template were removed from the provider side, but still exist as
archived on vmdb. The purpose of the PR is to provide a clear failure
message when there is no EMS.

https://bugzilla.redhat.com/show_bug.cgi?id=1471124
@masayag masayag force-pushed the fail_when_vm_or_template_has_no_ems branch from a0dcf2a to 92ed48a Compare August 15, 2017 11:38
@miq-bot
Copy link
Member

miq-bot commented Aug 15, 2017

Checked commit masayag@92ed48a with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
2 files checked, 0 offenses detected
Everything looks fine. 👍

Copy link
Contributor

@syncrou syncrou left a comment

Choose a reason for hiding this comment

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

👍 LGTM

@gmcculloug gmcculloug merged commit fa24dff into ManageIQ:master Aug 15, 2017
@gmcculloug gmcculloug added this to the Sprint 67 Ending Aug 21, 2017 milestone Aug 15, 2017
simaishi pushed a commit that referenced this pull request Aug 15, 2017
@simaishi
Copy link
Contributor

Fine backport details:

$ git log -1
commit 172f4eb59262d84195a4dbe7f4910f41d029973a
Author: Greg McCullough <gmccullo@redhat.com>
Date:   Tue Aug 15 08:00:35 2017 -0400

    Merge pull request #15807 from masayag/fail_when_vm_or_template_has_no_ems
    
    Fail with descriptive message when no EMS
    (cherry picked from commit fa24dfff1fec419b88fb47c531c808aca3f35d89)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1481845

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

Fail with descriptive message when no EMS
(cherry picked from commit fa24dff)

https://bugzilla.redhat.com/show_bug.cgi?id=1481845
@masayag masayag deleted the fail_when_vm_or_template_has_no_ems branch June 27, 2018 20:29
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.

5 participants