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

Simplify vm key update code path #243

Merged
merged 1 commit into from
Jun 7, 2017

Conversation

davidvossel
Copy link
Member

Hopefully this kind of patch is welcome :-)

I encountered this during a code walk through. I'm trying to become familiar with some of the more critical code paths so I'll have a better overall understanding of how the system performs.

The vm Execute function was pretty difficult for me to follow. Functionally this patch does not change anything. I do believe it is a worthwhile code quality improvement though.

@fabiand fabiand requested review from admiyo, rmohr and stu-gott June 7, 2017 07:10
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.

Definitely welcome. It increases the readability.

It seems like a unit test is failing.

if fetchedVM.(*v1.VM).Status.MigrationNodeName == d.host {
return true, nil
}
} else if result.Error().(*errors.StatusError).Status().Code != int32(http.StatusNotFound) {
Copy link
Member

Choose a reason for hiding this comment

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

Since you are already refactoring, could you change this line to !errors.IsNotFound(result.Error())? You can find errors it in the client-go library.

Copy link
Member Author

Choose a reason for hiding this comment

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

yup, np

func (d *VMHandlerDispatch) isMigrationDestination(vmName string) (bool, error) {

// If we don't have the VM in the cache, it could be that it is currently migrating to us
result := d.restClient.Get().Name(vmName).Resource("vms").Namespace(kubeapi.NamespaceDefault).Do()
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 probably also become easier to read, when we start using our Kubevirt client. If you want to integrate it, instead of the rest client, you can find the VM core client in pkg/kubecli/kubevirt.go. An instance can be obtained via kubecli.GetKubevirtClient() (instead of the kubecli.GetRESTClient()).

Copy link
Member Author

Choose a reason for hiding this comment

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

yup, i addressed this in a second patch.

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.

Minor comments only. Looks good!

queue.AddRateLimited(key)
return
} else if isDestination {
Copy link
Member

Choose a reason for hiding this comment

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

The error handling block returns so this doesn't need to be an "else" block. I'd find the code easier to follow without it, but that's simply personal preference.

Copy link
Member Author

Choose a reason for hiding this comment

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

agreed

@@ -226,6 +189,73 @@ func MapPersistentVolumes(vm *v1.VM, restClient cache.Getter, namespace string)
return vmCopy, nil
}

func (d *VMHandlerDispatch) processVmUpdate(vm *v1.VM, exists bool) error {
Copy link
Member

Choose a reason for hiding this comment

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

How would you feel about reversing the tense of the "exists" boolean passed into this function? I think it might convey more meaning as a function parameter if it were named something along the lines of "delete" or "shouldDelete" etc...

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, makes sense to me.

@davidvossel davidvossel force-pushed the vm-execute-refactor branch 3 times, most recently from 70f45d2 to 3abe722 Compare June 7, 2017 20:46
@davidvossel
Copy link
Member Author

Okay, patch has been updated to address feedback and fix the regression test failure.

I opted not to include the work I began on replacing the restClient with the virt core client. That work started to become more involved than just a refactor. I may submit it in a later pull request.

@davidvossel
Copy link
Member Author

I was able to get 27/27 of the functional tests pass as well with this change :-)

@admiyo admiyo merged commit 8b4a9c4 into kubevirt:master Jun 7, 2017
@stu-gott
Copy link
Member

stu-gott commented Jun 7, 2017

Hold on. don't merge this just yet.

Edit: Sorry go ahead. A test case failed that I'd never seen before so I just wanted to verify it was a transient. Nice work @davidvossel

@davidvossel
Copy link
Member Author

@stu-gott I've noticed a few transient failures with console related functional tests.

@rmohr
Copy link
Member

rmohr commented Jun 8, 2017

👍

mzzgaopeng pushed a commit to mzzgaopeng/kubevirt that referenced this pull request Mar 8, 2021
…update-email

MAINTAINERS: Update @tomdee email address
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

4 participants