Conversation
Signed-off-by: clyi <clyi@alauda.io>
Summary of ChangesHello @changluyi, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Virtual Machine Instance (VMI) migration process by introducing a waiting period for the VMI to reach a ready state after a migration completes. This ensures that network configurations related to the migration are only finalized once the VMI is stable and operational, preventing potential race conditions or premature cleanup of network options on the logical switch port. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a delay before cleaning up OVN migration options for a KubeVirt VMI after migration is complete. This is achieved by waiting for the VMI to become 'Ready'. While the intention to prevent traffic disruption is good, the current implementation uses a blocking wait within the controller worker, which can negatively impact controller performance by delaying the processing of other migration events. My review includes a suggestion to adopt a non-blocking approach that is more idiomatic for Kubernetes controllers.
| if err := c.waitForVMIReady(vmi); err != nil { | ||
| err = fmt.Errorf("failed to wait for VMI %s to be ready: %w", vmi.Name, err) | ||
| klog.Error(err) | ||
| return err | ||
| } |
There was a problem hiding this comment.
The waitForVMIReady function introduces a blocking poll loop that can hold a controller worker for up to a minute. As the VMI migration handler runs as a single worker, this will serialize the completion of all migrations and can cause significant processing delays.
A more idiomatic controller pattern is to use the workqueue's requeueing mechanism for polling. Instead of blocking, check for VMI readiness once. If it's not ready, return an error to trigger a requeue. This allows the worker to process other items.
I recommend replacing the blocking wait with a non-blocking readiness check. This also makes the waitForVMIReady function unnecessary, and it can be removed.
currentVMI, err := c.config.KubevirtClient.VirtualMachineInstance(vmi.Namespace).Get(context.TODO(), vmi.Name, metav1.GetOptions{})
if err != nil {
if k8serrors.IsNotFound(err) {
klog.Warningf("VMI %s not found, proceeding to clean migrate options", vmi.Name)
} else {
err = fmt.Errorf("failed to get VMI %s to check readiness: %w", vmi.Name, err)
klog.Error(err)
return err
}
} else if !c.isVMIReady(currentVMI) {
klog.Infof("VMI %s is not ready yet after migration, requeueing", vmi.Name)
return fmt.Errorf("VMI %s is not ready yet", vmi.Name)
}
Pull Request Test Coverage Report for Build 19057062882Details
💛 - Coveralls |
Pull Request
What type of this PR
Examples of user facing changes:
Which issue(s) this PR fixes
Fixes #(issue-number)