-
Notifications
You must be signed in to change notification settings - Fork 458
support k8s host vm vip type #5148
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
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.
Hello @zbb88888, 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!
Summary of Changes
This pull request introduces support for a new type of Virtual IP (VIP) called KubeHostVMVip
. This new VIP type is intended for use with Kubernetes host network pods running VMs, allowing these VMs to utilize Kube-OVN's VIP functionality. The changes primarily involve modifying the controller to handle this new VIP type, specifically in IP address acquisition and LSP (Logical Switch Port) creation and deletion. The garbage collection logic is also updated to avoid deleting LSPs associated with these new VIPs.
Highlights
- New VIP Type: Introduces a new
KubeHostVMVip
type to support VMs running on Kubernetes host network pods. - IP Address Acquisition: Modifies the
acquireStaticIPAddress
function to accept amacPointer
to allow specifying a MAC address when acquiring a static IP for the VIP. - LSP Management: Updates the VIP controller to create and delete LSPs for
KubeHostVMVip
types, ensuring proper network connectivity for the VMs. - Garbage Collection: Modifies the garbage collection logic to prevent deletion of LSPs associated with
KubeHostVMVip
resources.
Changelog
Click here to see the changelog
- pkg/controller/gc.go
- Adds logic to prevent garbage collection of LSPs associated with VIPs, specifically those of type
KubeHostVMVip
. - Introduces a
vipsMap
to track VIP-related LSPs.
- Adds logic to prevent garbage collection of LSPs associated with VIPs, specifically those of type
- pkg/controller/ip.go
- Modifies
acquireStaticIPAddress
to accept amacPointer
argument.
- Modifies
- pkg/controller/ovn_eip.go
- Updates calls to
acquireStaticIPAddress
to passnil
for themacPointer
.
- Updates calls to
- pkg/controller/subnet.go
- Updates calls to
acquireStaticIPAddress
to passnil
for themacPointer
.
- Updates calls to
- pkg/controller/vip.go
- Modifies
handleAddVirtualIP
to handle theKubeHostVMVip
type, including creating LSPs for the VM's NIC IP. - Adds logic to use the VIP's MAC address when acquiring a static IP, if provided.
- Updates
handleDelVirtualIP
to delete LSPs associated with any VIP type, not justSwitchLBRuleVip
. - Adds a check in
handleUpdateVirtualParents
to return early forKubeHostVMVip
types.
- Modifies
- pkg/util/const.go
- Adds a new constant,
KubeHostVMVip
, to represent the new VIP type.
- Adds a new constant,
Using Gemini Code Assist
The 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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
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 .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and 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 to provide feedback.
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.
A virtual IP's gentle grace,
For VMs in a host's embrace,
Connectivity's art,
A brand new start,
In Kubernetes' digital space.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
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.
Code Review
The pull request introduces support for K8s host network VM VIPs, allowing VMs to use Kube-OVN VIPs. The changes involve modifications to gc.go, ip.go, ovn_eip.go, subnet.go, vip.go, and const.go. Overall, the code seems well-structured and addresses the intended functionality. However, there are a few areas that could benefit from closer examination and potential improvement.
Summary of Findings
- Missing MAC Address Handling in acquireStaticIPAddress: The
acquireStaticIPAddress
function inpkg/controller/ip.go
is modified to accept amacPointer
, but the logic to actually use this pointer is missing. This could lead to incorrect MAC address assignments for static IPs. - Inconsistent use of subnet.Spec.Provider: In
pkg/controller/vip.go
, thesubnet.Spec.Provider
is used to determine the port name. It's important to ensure that this value is consistent and reliable across all VIP types, especially the newKubeHostVMVip
. - TODO comment: The TODO comment in
pkg/controller/vip.go
regarding cleaning VIPs in the parent port AAP list should be addressed to ensure proper resource management.
Merge Readiness
The pull request introduces significant functionality and requires careful review to ensure correctness and stability. The missing MAC address handling in acquireStaticIPAddress
is a high-severity issue that must be addressed before merging. The inconsistent use of subnet.Spec.Provider
and the TODO comment should also be addressed. I am unable to approve this pull request, and recommend that it not be merged until these issues are resolved, and that others review and approve this code before merging.
pkg/controller/vip.go
Outdated
if ipStr != "" && vip.Spec.MacAddress != "" { | ||
macPointer = &vip.Spec.MacAddress | ||
v4ip, v6ip, mac, err = c.acquireStaticIPAddress(subnet.Name, vip.Name, portName, ipStr, macPointer) |
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 condition checks if both ipStr
and vip.Spec.MacAddress
are not empty before assigning the macPointer
. It might be more appropriate to check if vip.Spec.MacAddress
is provided regardless of ipStr
and pass the macPointer
accordingly. This would allow specifying a MAC address even when an IP is dynamically assigned.
Pull Request Test Coverage Report for Build 14505800466Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
Signed-off-by: zbb88888 <[email protected]>
Signed-off-by: zbb88888 <[email protected]>
Co-authored-by: 张祖建 <[email protected]>
--------- Signed-off-by: zbb88888 <[email protected]> Co-authored-by: 张祖建 <[email protected]> Signed-off-by: zhangbingbing2 <[email protected]>
Pull Request
What type of this PR
Examples of user facing changes:
Features
support host network pod run VM use kube-ovn VIP
provide a simple way to run a VM with kube-ovn
test case:
performance test:
qemu + linux tap ~ 75% Linux veth-pair in ns
latency
qemu + linux tap 15us vs 5us Linux veth-pair in ns
Which issue(s) this PR fixes
Fixes #(issue-number)