-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
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.
Definitely welcome. It increases the readability.
It seems like a unit test is failing.
pkg/virt-handler/vm.go
Outdated
if fetchedVM.(*v1.VM).Status.MigrationNodeName == d.host { | ||
return true, nil | ||
} | ||
} else if result.Error().(*errors.StatusError).Status().Code != int32(http.StatusNotFound) { |
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.
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.
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.
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() |
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 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()
).
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.
yup, i addressed this in a second patch.
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.
Minor comments only. Looks good!
pkg/virt-handler/vm.go
Outdated
queue.AddRateLimited(key) | ||
return | ||
} else if isDestination { |
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.
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.
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.
agreed
pkg/virt-handler/vm.go
Outdated
@@ -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 { |
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.
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...
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.
yep, makes sense to me.
70f45d2
to
3abe722
Compare
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. |
I was able to get 27/27 of the functional tests pass as well with this change :-) |
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 |
@stu-gott I've noticed a few transient failures with console related functional tests. |
👍 |
…update-email MAINTAINERS: Update @tomdee email address
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.