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
Migration controller #118
Migration controller #118
Conversation
35fcdc4
to
b2e42ed
Compare
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.
Very nice! 👍
pkg/virt-controller/services/vm.go
Outdated
} | ||
if _, err := v.KubeCli.Core().Pods(v1.NamespaceDefault).Create(pod); err != nil { | ||
|
||
err2 := UpdateMigration(migration) |
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.
Lower case, as it is just a helper and should not be exported
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.
But its called from Watch, too.
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.
Oh right ...
tests/vm_migration_test.go
Outdated
}) | ||
|
||
AfterEach(func() { | ||
restClient.Delete().Resource("migrations").Namespace(api.NamespaceDefault).Name(migration.ObjectMeta.Name).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.
Could you add the deletion of all migrations to tests.MustCleanup()?
tests/vm_migration_test.go
Outdated
Expect(err).To(BeNil()) | ||
var r runtime.Object = nil | ||
|
||
time.Sleep(time.Second * 3) |
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.
Use Eventually()
tests/vm_migration_test.go
Outdated
Expect(vmR.ObjectMeta.Name).To(Equal(vm.ObjectMeta.Name)) | ||
|
||
//wait for the controller to update status | ||
time.Sleep(time.Second * 3) |
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.
Use Eventually()
tests/vm_migration_test.go
Outdated
err = restClient.Post().Resource("migrations").Namespace(api.NamespaceDefault).Body(migration).Do().Error() | ||
Expect(err).To(BeNil()) | ||
//wait for the controller to update status | ||
time.Sleep(time.Second * 3) |
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.
Use Eventually()
tests/vm_migration_test.go
Outdated
|
||
Context("New Migration given", func() { | ||
|
||
It("Should be No migrations", func() { |
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 test here seems to be pretty redundant ... BeforeEach and AfterEach should make sure that the system is clean ...
pkg/virt-controller/services/vm.go
Outdated
return err | ||
} | ||
|
||
func GetDefinedVMs(vmName string) (*corev1.VM, error) { |
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.
Looks like this can just return one VM.
Maybe FetchVM
, would be ok too? The Fetch
better indicates, that it is not just looked up in the cache ...
pkg/virt-controller/services/vm.go
Outdated
|
||
func GetDefinedVMs(vmName string) (*corev1.VM, error) { | ||
restClient, err := kubecli.GetRESTClient() | ||
list, err := restClient.Get().Namespace(v1.NamespaceDefault).Resource("vms").Name(vmName).Do().Get() |
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.
list
should be vm
pkg/virt-controller/services/vm.go
Outdated
return nil, err | ||
} | ||
vm := list.(*corev1.VM) | ||
return vm, err |
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.
Mabye return vm.(*corev1.VM), nil
instead?
|
||
// Retrieve the Migration | ||
if !exists { | ||
cleanupOldMigration(key, queue, migrationService) |
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 would keep the creation of the old Migration object in the main loop and just do the cleanup in the function.
In general the same things apply like to the refactoring PR. The functions seem very polluted with infra parameters ...
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'd prefer if the changeset titled "Whitespace cleanup to fix formate check" were squashed
@@ -341,6 +363,9 @@ type MigrationSpec struct { | |||
type MigrationPhase string | |||
|
|||
const ( | |||
// Create Migration has been called but nothing has been done with it | |||
MigrationUnknown MigrationPhase = "" |
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.
Is there a compelling reason to make this an empty string? It would be more consistent to make this:
- MigrationUnknown MigrationPhase = "Unknown"
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.
It means, that so far, no component touched it, if there is no state present ...
tests/vm_migration_test.go
Outdated
It("Should be No migrations", func() { | ||
|
||
b, err := restClient.Get().Resource("migrations").Namespace(api.NamespaceDefault).Name(migration.ObjectMeta.Name).DoRaw() | ||
Expect(err).ToNot(BeNil()) |
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.
Expect(err).ToNot(HaveOccurred())
This appears a lot in this file so I'll just reference this once.
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.
Good catch
pkg/virt-api/rest/kubeproxy_test.go
Outdated
@@ -25,6 +25,7 @@ import ( | |||
"kubevirt.io/kubevirt/pkg/logging" | |||
rest2 "kubevirt.io/kubevirt/pkg/rest" | |||
. "kubevirt.io/kubevirt/pkg/virt-api/rest" | |||
matchers "kubevirt.io/kubevirt/test" |
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.
Could you do a "." import: . "kubevirt.io/kubevirt/test
?
tests/vm_migration_test.go
Outdated
@@ -93,30 +91,26 @@ var _ = Describe("VmMigration", func() { | |||
|
|||
time.Sleep(time.Second * 3) |
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 is a time.Sleep left
tests/vm_migration_test.go
Outdated
r, err = restClient.Get().Resource("vms").Namespace(api.NamespaceDefault).Name(vm.ObjectMeta.Name).Do().Get() | ||
var vmR *v1.VM = r.(*v1.VM) | ||
Expect(vmR.ObjectMeta.Name).To(Equal(vm.ObjectMeta.Name)) | ||
Eventually(func() string { |
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.
You probably have to give your Eventually calls an overall timeout and a polling intervall different to 1 second and 10 ms. Or did it just work for you?
9267697
to
71451d3
Compare
All comments from the last review were addressed. I had to rebase to push. I want to make one last push to try and get Unit test coverage before I squash the commits |
86d0445
to
7f22181
Compare
retest this please |
1a6aa0b
to
70621c1
Compare
Starts the migration process, through the launching of the target pod. Increased unit test coverage for both migration and VMs
70621c1
to
6216ff9
Compare
retest this please |
ghttp.RespondWithJSONEncoded(http.StatusOK, migration), | ||
), | ||
|
||
/*ghttp.CombineHandlers( |
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.
That can be removed
As first step to implement node<->node communication using secondary nics we need to have unique mac address on them. Signed-off-by: Quique Llorente <ellorent@redhat.com>
No description provided.