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

Migration controller #118

Merged
merged 2 commits into from Mar 9, 2017
Merged

Migration controller #118

merged 2 commits into from Mar 9, 2017

Conversation

admiyo
Copy link
Contributor

@admiyo admiyo commented Mar 1, 2017

No description provided.

@admiyo admiyo force-pushed the migration-controller branch 4 times, most recently from 35fcdc4 to b2e42ed Compare March 6, 2017 12:02
@admiyo admiyo changed the title WIP Migration controller Migration controller Mar 6, 2017
Copy link
Member

@rmohr rmohr left a comment

Choose a reason for hiding this comment

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

Very nice! 👍

}
if _, err := v.KubeCli.Core().Pods(v1.NamespaceDefault).Create(pod); err != nil {

err2 := UpdateMigration(migration)
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

Oh right ...

})

AfterEach(func() {
restClient.Delete().Resource("migrations").Namespace(api.NamespaceDefault).Name(migration.ObjectMeta.Name).Do()
Copy link
Member

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()?

Expect(err).To(BeNil())
var r runtime.Object = nil

time.Sleep(time.Second * 3)
Copy link
Member

Choose a reason for hiding this comment

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

Use Eventually()

Expect(vmR.ObjectMeta.Name).To(Equal(vm.ObjectMeta.Name))

//wait for the controller to update status
time.Sleep(time.Second * 3)
Copy link
Member

Choose a reason for hiding this comment

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

Use Eventually()

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)
Copy link
Member

Choose a reason for hiding this comment

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

Use Eventually()


Context("New Migration given", func() {

It("Should be No migrations", func() {
Copy link
Member

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 ...

return err
}

func GetDefinedVMs(vmName string) (*corev1.VM, error) {
Copy link
Member

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 ...


func GetDefinedVMs(vmName string) (*corev1.VM, error) {
restClient, err := kubecli.GetRESTClient()
list, err := restClient.Get().Namespace(v1.NamespaceDefault).Resource("vms").Name(vmName).Do().Get()
Copy link
Member

Choose a reason for hiding this comment

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

list should be vm

return nil, err
}
vm := list.(*corev1.VM)
return vm, err
Copy link
Member

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)
Copy link
Member

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 ...

Copy link
Member

@stu-gott stu-gott left a 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 = ""
Copy link
Member

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"

Copy link
Member

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 ...

It("Should be No migrations", func() {

b, err := restClient.Get().Resource("migrations").Namespace(api.NamespaceDefault).Name(migration.ObjectMeta.Name).DoRaw()
Expect(err).ToNot(BeNil())
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

Good catch

@@ -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"
Copy link
Member

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?

@@ -93,30 +91,26 @@ var _ = Describe("VmMigration", func() {

time.Sleep(time.Second * 3)
Copy link
Member

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

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 {
Copy link
Member

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?

@admiyo
Copy link
Contributor Author

admiyo commented Mar 7, 2017

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

@rmohr
Copy link
Member

rmohr commented Mar 8, 2017

retest this please

@admiyo admiyo force-pushed the migration-controller branch 3 times, most recently from 1a6aa0b to 70621c1 Compare March 8, 2017 19:50
Starts the migration process, through the launching of the target pod.
Increased unit test coverage for both migration and VMs
@rmohr
Copy link
Member

rmohr commented Mar 9, 2017

retest this please

ghttp.RespondWithJSONEncoded(http.StatusOK, migration),
),

/*ghttp.CombineHandlers(
Copy link
Member

Choose a reason for hiding this comment

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

That can be removed

@admiyo admiyo merged commit 5f8af89 into kubevirt:master Mar 9, 2017
rmohr pushed a commit that referenced this pull request Mar 13, 2017
@admiyo admiyo deleted the migration-controller branch April 7, 2017 17:19
kubevirt-bot pushed a commit to kubevirt-bot/kubevirt that referenced this pull request Dec 7, 2021
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants