-
Notifications
You must be signed in to change notification settings - Fork 898
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] Add VM validation for warm migration eligibility and updated specs to … #19401
Conversation
@thearifismail 'djberg96, agrare' is an invalid reviewer, ignoring... |
I generally favor positives over negatives, because then you end up with double negatives. In other words, rather than read this:
It's easier to read this:
|
Done. Now it has |
This can be written as:
|
dccfde7
to
ceb62a1
Compare
@thearifismail 'fdupont-redhat' is an invalid reviewer, ignoring... |
@miq-bot add_label transformation |
I would have expected the validation code to be in app/models/transformation_mapping/vm_migration_validator.rb, because that's where the other validations are. Basically, I would add a new method to check if VM can be warm migrated, with only one check. Then, I'd call it from Then, the question is: how do you know that warm migration should be checked ? The |
To ensure that warm migration check did not block cold migrations, the reference to migration was needed in |
As long as the UI is able to get the information, I'm fine with that. |
In the spec, I don't see any test where the value is |
@thearifismail I'm guessing you don't want your byebug history as part of the PR. ;) |
Removed it already. |
@@ -63,6 +63,7 @@ def validate_config_info(options) | |||
raise _("Invalid VM found #{vm_obj.name}") if vm_obj.invalid? | |||
|
|||
vm_options = {} | |||
vm_options[:warm_migration_compatible] = vm_obj.snapshots.blank? |
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.
This assumes that having snapshots is the only thing that would prevent warm migration which might not always be the case. How about a supports feature mixin on the (I assume only VMware VM) model? Then this becomes vm_object.supports_warm_migration?
61e755f
to
9ba2cfa
Compare
Some gems needed to get updated. Running |
2c7f2ca
to
99d4c7f
Compare
expect(service_template.vm_resources.find_by(:resource_id => vm2.id).options) | ||
.to eq("pre_ansible_playbook_service_template_id" => apst.id, "post_ansible_playbook_service_template_id" => apst.id, "osp_security_group_id" => security_group1.id, "osp_flavor_id" => flavor1.id) | ||
|
||
stub_const("VirtualMachine", Class.new(ManageIQ::Providers::InfraManager::Vm) 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.
Can you namespace this? ManageIQ::Providers::InfraManager::WarmMigrationVm
or something?
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. Changed VirtualMachine
to ManageIQ::Providers::InfraManager::WarmMigrationVm
.
expect(service_template.vm_resources.find_by(:resource_id => vm3.id).options) | ||
.to eq("pre_ansible_playbook_service_template_id" => apst.id, "post_ansible_playbook_service_template_id" => apst.id, "osp_security_group_id" => security_group2.id, "osp_flavor_id" => flavor2.id) | ||
|
||
stub_const("VirtualMachine", Class.new(ManageIQ::Providers::InfraManager::Vm) 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.
This should be in a before do; end
block at the top so you don't have to re-declare it everytime.
You can also e.g. let(:vm_with_snapshots) { VirtualMachine.new() }
so you can reuse the instance
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!
end) | ||
|
||
vm1_options = service_template.vm_resources.find_by(:resource_id => vm1.id).options | ||
vm1_options["warm_migration_compatible"] = VirtualMachine.new(:snapshots => vm1.snapshots).supports_warm_migrate? |
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.
Instead of using vm1.snapshots
could this warm-migration compatible class be vm1
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 did start with vm1 but using VirtualMachine.new(:vm => vm1).supports_warm_migrate?
or VirtualMachine.new(:vm_or_template => vm1).supports_warm_migrate?
would complain that :vm
, vm_or_template
were UNKNOWN. Using :snapshot
was the only I could get it 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.
No, instead of let(:vm1) { FactoryBot.create(:vm_or_template) }
you do let(:vm1) { VirtualMachine.new }
before do | ||
stub_const("ManageIQ::Providers::InfraManager::WarmMigrationVm", Class.new(ManageIQ::Providers::InfraManager::Vm) do | ||
supports :warm_migrate do | ||
unsupported_reason_add(:warm_migrate, _('Warm migratiobn can not migrate a VM with snapshots')) if snapshots.present? |
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.
"migratiobn"
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.
Fixed.
.to eq("pre_ansible_playbook_service_template_id" => apst.id, "post_ansible_playbook_service_template_id" => apst.id, "osp_security_group_id" => security_group1.id, "osp_flavor_id" => flavor1.id) | ||
|
||
vm1_options = service_template.vm_resources.find_by(:resource_id => vm1.id).options | ||
vm1_options["warm_migration_compatible"] = ManageIQ::Providers::InfraManager::WarmMigrationVm.new(:snapshots => vm1.snapshots).supports_warm_migrate? |
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.
Shouldn't this be set by the actual code instead of being set in the tests?
Quickly chatted with @agrare. Using the |
…deal with warm migration
f102cca
to
e43f670
Compare
Checked commits thearifismail/manageiq@80b367f~...e43f670 with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 |
Kicking the cross-repo tests ManageIQ/manageiq-cross_repo-tests#1 |
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.
Going to merge this now because these classes are going to be extracted into the v2v repo shortly
@fdupont-redhat |
@miq-bot add-label ivanchuk/yes |
[V2V] Add VM validation for warm migration eligibility and updated specs to … (cherry picked from commit 4d3d171) https://bugzilla.redhat.com/show_bug.cgi?id=1790538
Ivanchuk backport details:
|
For warm migration, we need to limit the list of selectable VMs in the migration plan wizard. This is done by adding
warm_migration_incompatible
property to VMs inapp/models/service_template_transformation_plan/validate_config_info.rb
. The criteria is that the VM must not have snapshots.https://bugzilla.redhat.com/show_bug.cgi?id=1760040