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

Add Migrate support to RHEV provider #11366

Merged
merged 2 commits into from
Nov 3, 2016

Conversation

jelkosz
Copy link
Contributor

@jelkosz jelkosz commented Sep 19, 2016

A simple implementation which adds the support to migrating of virtual machines in the ovirt/rhev.

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

def vm_migrate(vm, options = {})
host_id = URI(options[:host]).path.split('/').last

mig_options = {
Copy link
Member

Choose a reason for hiding this comment

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

What is mig? Is that migration? If so, prefer spelling it out for readability/clarity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, migration. Changed.

:id => host_id
}
}
connection = connect(:version => 4)
Copy link
Member

Choose a reason for hiding this comment

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

Prefer with_provider_connection helper which auto-closes.

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

end

def field_unsupported(key)
@manager.respond_to? :unsupported_migration_options and
Copy link
Member

Choose a reason for hiding this comment

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

Prefer && over and

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

@Fryguy
Copy link
Member

Fryguy commented Sep 19, 2016

@gmcculloug Please review. I'm not sure about the changes for unsupported fields. I feel like they should be at the base class, but you might know better.

@jelkosz jelkosz force-pushed the add-migrate-to-rhev-provider branch 2 times, most recently from 447c1e4 to 7914d29 Compare September 20, 2016 11:18
@jelkosz
Copy link
Contributor Author

jelkosz commented Sep 20, 2016

}
}

with_provider_connection(:version => 4) do |connection|
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@borod108 do you know how to behave in case of old api level?

@jelkosz
Copy link
Contributor Author

jelkosz commented Sep 22, 2016

@borod108 have you ever seen this travis failure? I have no idea if that has anything to do with my patch, it fails on
Errno::ENOENT: No such file or directory @ rb_sysopen - /home/travis/build/ManageIQ/manageiq/log/last_settings.txt

@borod108
Copy link

@jelkosz nope, did you try to run tests on local?
To me it does not seem anything you did might cause this, so I would try to fetch master rebase and push again.

@chessbyte chessbyte changed the title added support of migrate to redhat provider added support of migrate to rhev provider Sep 22, 2016
@chessbyte chessbyte changed the title added support of migrate to rhev provider Add Migrate support to RHEV provider Sep 22, 2016
@jelkosz jelkosz force-pushed the add-migrate-to-rhev-provider branch 3 times, most recently from bcae041 to 80b556c Compare September 23, 2016 12:26
@miq-bot
Copy link
Member

miq-bot commented Sep 26, 2016

<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush.

@jelkosz
Copy link
Contributor Author

jelkosz commented Sep 29, 2016

@miq-bot add_label euwe/yes

@@ -22,6 +22,8 @@ def get_source_and_targets(refresh = false)
return @target_resource = {} if ems.length != 1

result = {:ems => ci_to_hash_struct(ems.first)}
@manager = ems.first
Copy link
Member

@durandom durandom Oct 10, 2016

Choose a reason for hiding this comment

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

I think you can remove this here and inline that below in field_unsupported
Because like this its adding a side effect to this method

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 don't see any good way of doing it since the ems is a result of
ems = @values[:src_ids].to_miq_a.collect { |v_id| v = Vm.find_by_id(v_id); v.ext_management_system }.uniq.compact

which I don't really want to repeat in field_unsupported.

But this method anyway have side effects so not sure this is an issue.

Copy link
Member

Choose a reason for hiding this comment

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

how about moving ems into its own method with memoization then?

But lets wait for @mkanoor to chime in

Copy link
Contributor

Choose a reason for hiding this comment

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

@bdunne
Can you please help review this it relates to RHEVM

super unless field_unsupported(key)
end

def field_unsupported(key)
Copy link
Member

Choose a reason for hiding this comment

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

@mkanoor can you have a look at this or somebody from your team that has experience with this?
I'm not sure if this is how we handle partially supported fields

@oourfali
Copy link

live migration

@jelkosz
Copy link
Contributor Author

jelkosz commented Oct 13, 2016

@miq-bot assign @mkanoor

@miq-bot miq-bot assigned mkanoor and unassigned gmcculloug Oct 13, 2016
Copy link
Member

@bdunne bdunne left a comment

Choose a reason for hiding this comment

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

This needs tests

@@ -100,6 +100,20 @@ def prepare_disk(disk_spec, ems_storage_uid)
}
end

def vm_migrate(vm, options = {})
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this live under the VM operations instead of the manager?

@@ -118,4 +132,8 @@ def remove_disks(disks, vm)
disks.each { |disk_id| service.attachment_service(disk_id).remove }
end
end

def unsupported_migration_options
Copy link
Member

Choose a reason for hiding this comment

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

same

@@ -38,6 +40,15 @@ def get_source_and_targets(refresh = false)
@target_resource = result
end

def add_target(dialog_key, key, klass, result)
super unless field_unsupported(key)
Copy link
Member

Choose a reason for hiding this comment

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

It would be great if logic was positive case rather than the current double negative "unless unsupported"

@gmcculloug gmcculloug self-assigned this Oct 18, 2016
@jelkosz jelkosz force-pushed the add-migrate-to-rhev-provider branch 2 times, most recently from 028ab6d to b8283f7 Compare October 25, 2016 08:11
@@ -119,4 +119,23 @@ def remove_disks(disks, vm)
disks.each { |disk_id| service.attachment_service(disk_id).remove }
end
end

def vm_migrate(vm, options = {})
Copy link
Member

Choose a reason for hiding this comment

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

I was expecting migrate to be a VM operation. Any reason that this is on the infra manager instead?

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 was trying to make it similar to the vmware provider where it is also placed in the infra manager. Also, it needs to be called from the vm_migrate_workflow

Copy link
Member

Choose a reason for hiding this comment

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

yes, this how our api currently works. VmOrTemaplate#migrate calls VmOrTemaplate#raw_migrate which calls Ems#vm_migrate - so this should work

@jelkosz
Copy link
Contributor Author

jelkosz commented Oct 31, 2016

@durandom @bdunne so what you guys think?

@durandom
Copy link
Member

@bdunne I'm fine with the non-automate part. If you think the workflow part is good, I think this can be merged.

@bdunne
Copy link
Member

bdunne commented Oct 31, 2016

@jelkosz There are a couple of remaining rubocop comments. Otherwise looks good 👍

@jelkosz jelkosz force-pushed the add-migrate-to-rhev-provider branch from b8283f7 to 3866681 Compare November 1, 2016 08:42
@durandom
Copy link
Member

durandom commented Nov 1, 2016

@jelkosz thanks for addressing the rubocop stuff

@gmcculloug can you merge this please? @bdunne and me are 👍

@jelkosz jelkosz force-pushed the add-migrate-to-rhev-provider branch from 3866681 to bc4c103 Compare November 3, 2016 11:55
@miq-bot
Copy link
Member

miq-bot commented Nov 3, 2016

Checked commits jelkosz/manageiq@1581e45~...bc4c103 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
6 files checked, 0 offenses detected
Everything looks good. 🏆

@jelkosz
Copy link
Contributor Author

jelkosz commented Nov 3, 2016

@gmcculloug @bdunne Only rebased and added a check to allow this code only for api version 4. The travis failure is not related, all commits are failing on this same issue.

@jelkosz
Copy link
Contributor Author

jelkosz commented Nov 3, 2016

@miq-bot add_label blocker

@miq-bot miq-bot added the blocker label Nov 3, 2016
@gmcculloug gmcculloug merged commit 99adc9d into ManageIQ:master Nov 3, 2016
@gmcculloug gmcculloug added this to the Sprint 49 Ending Nov 14, 2016 milestone Nov 3, 2016
@gmcculloug
Copy link
Member

@jelkosz Is there a BZ related to this change?

@jelkosz
Copy link
Contributor Author

jelkosz commented Nov 3, 2016

@chessbyte
Copy link
Member

chessbyte pushed a commit that referenced this pull request Nov 8, 2016
@chessbyte
Copy link
Member

Euwe Backport details:

$ git log -1
commit ab440c5fe20e3e35ceb5e2443b0ae1250b032ee5
Author: Greg McCullough <gmccullo@redhat.com>
Date:   Thu Nov 3 14:43:17 2016 -0400

    Merge pull request #11366 from jelkosz/add-migrate-to-rhev-provider

    Add Migrate support to RHEV provider
    (cherry picked from commit 99adc9df0da7a25bfd220a153680cef6fc9e767c)

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

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.

10 participants