-
Notifications
You must be signed in to change notification settings - Fork 897
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
[V2V] Remove fatal nil IP check in preflight check #18496
[V2V] Remove fatal nil IP check in preflight check #18496
Conversation
@fdupont-redhat 'agrare, djberg96, jameswnl' is an invalid reviewer, ignoring... |
@miq-bot add-reviewer agrare |
@@ -459,7 +459,12 @@ | |||
|
|||
it "fails if network IP address is nil" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to update this as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -459,7 +459,12 @@ | |||
|
|||
it "fails if network IP address is nil" do | |||
allow(src_nic_2).to receive(:network).and_return(src_network_2b) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we rename this src_network_2b
to be something obvious e.g. nil_ip_network
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Also renamed src_network_2a
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this validation is openshift specific it should be extracted to the openshift repo in the openshift subclass
@@ -256,12 +256,12 @@ def calculate_network_mappings | |||
source_network = nic.lan | |||
destination_network = transformation_destination(source_network) | |||
raise "[#{source.name}] NIC #{nic.device_name} [#{source_network.name}] has no mapping." if destination_network.nil? | |||
raise "[#{source.name}] NIC #{nic.device_name} [#{source_network.name}] has an empty IP address." if nic.network.try(:ipaddress).nil? | |||
raise "[#{source.name}] NIC #{nic.device_name} [#{source_network.name}] has an empty IP address." if nic.network.try(:ipaddress).nil? && destination_ems.emstype == 'openstack' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👎 really don't like hard coding this into the common base class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The validation is specific to IMS. That's an IMS limitation due to the way CloudForms stores the IP addresses for a single NIC. When a NIC has a number of IPv4 or IPv6 addresses greater than 1, the Network object associated to the Nic object can have a nil IP address.
BTW, we also handle the various providers using send
with method names including the provider name. How different is that ? Shoud I split network_mappings
into network_mappings_rhevm
and network_mappings_openstack
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fdupont-redhat Let's create some scaffolding in the provider repo and put it there. I already have ServiceTemplateTransformationPlan
at https://github.com/ManageIQ/manageiq-providers-openstack/blob/master/app/models/manageiq/providers/openstack/cloud_manager/service_template_transformation_plan.rb.
So, how about we create ServiceTemplateTransformationPlanTask there as well (in its own file), and then put our rules in there. Let's establish a common interface method. Then have the core method use that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@djberg96 exactly as long as you actually have an instance of ManageIQ::Providers::Openstack::CloudManager::ServiceTemplateTransformationPlan
it'll call into that method first.
Typically we'd define
def calculate_network_mappings
super # call the base code
additional_super_awesome_validations_only_for_openstack
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's some magic happening at https://github.com/ManageIQ/manageiq/blob/master/app/models/miq_request.rb#L341 inside MiqRequest, but I think it will still work.
I would normally call super
, but since it's a loop, he might be better off just redefining the method completely, otherwise he'll have to loop again. That, or create some sort of common interface method for a validating check, but that's more work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading virt-v2v-wrapper code, it appears that a missing IP address is not a problem. What fails is a IP address with nil
value, as virt-v2v-wrapper will add the None
literal to the openstack
command. I discussed with Marco and he agreed that there are valid use cases for missing IP address, regardless of BZ#1657126, so we should not forcefully fail but rather prevent virt-v2v-wrapper failure. I updated the PR to reflect that and the network_mappings
is again generic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the PR title and description.
1b60ae0
to
db92d3c
Compare
:ip_address => nic.network.ipaddress | ||
} | ||
:ip_address => nic.network.try(:ipaddress) | ||
}.delete_if { |_, v| v.nil? } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hash#compact
is simpler. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed.
Checked commits fabiendupont/manageiq@a543ba9~...7d226da with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
…k_for_rhv [V2V] Remove fatal nil IP check in preflight check (cherry picked from commit 35f5025) Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1686049
Hammer backport details:
|
We introduced a check on empty IP address for NICs. However, this should only apply to migrations to OpenStack as it only breaks network port creation. This PR relaxes the check to limit it to migrations toward OpenStack.We introduced a check on empty IP address for NICs, because it made virt-v2v-wrapper fail when migrating to OpenStack. However, this was not limited to OpenStack and blocked migrations to RHV, so was too strict. Also, virt-v2v-wapper is able to handle NICs without IP address as long as the
ip_address
field is not part of the mapping we send to it. This PR removes the check on the IP address and removes theip_address
field if it'snil
.Associated RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1680487