-
Notifications
You must be signed in to change notification settings - Fork 458
enable check vlan conflict #5110
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
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: zbb88888 <[email protected]>
Signed-off-by: zbb88888 <[email protected]>
Signed-off-by: zbb88888 <[email protected]>
Signed-off-by: zbb88888 <[email protected]>
Signed-off-by: zbb88888 <[email protected]>
Signed-off-by: zbb88888 <[email protected]>
Signed-off-by: zbb88888 <[email protected]>
Signed-off-by: zbb88888 <[email protected]>
Signed-off-by: zbb88888 <[email protected]>
Signed-off-by: zbb88888 <[email protected]>
Signed-off-by: zbb88888 <[email protected]>
Signed-off-by: zbb88888 <[email protected]>
Signed-off-by: zbb88888 <[email protected]>
Signed-off-by: zbb88888 <[email protected]>
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 a mechanism to check for VLAN conflicts within the Kube-OVN environment. It ensures that newly created VLANs do not conflict with existing tunnel VLANs on nodes or other VLANs already present in the cluster. This is achieved by adding a conflict status to the VLAN CRD and implementing checks in both the kube-ovn-controller and kube-ovn-cni components. The changes include adding a new configuration option to enable/disable the VLAN conflict check, updating the VLAN status to reflect conflicts, and implementing periodic checks to identify and report conflicts.
Highlights
- VLAN Conflict Detection: Implements checks to prevent VLAN ID conflicts between newly created VLAN CRDs, existing tunnel VLANs on nodes, and other VLANs in the cluster.
- Kube-OVN Controller Changes: Modifies the kube-ovn-controller to ensure new VLAN CRDs do not conflict with tunnel NIC VLANs or existing VLANs before becoming effective. Sets the VLAN status to 'conflict' and marks the subnet as 'not ready' if a conflict is detected.
- Kube-OVN CNI Changes: Updates kube-ovn-cni to check for conflicts between new VLAN CRDs and tunnel VLANs, as well as existing VLAN sub-interfaces on nodes. Records a ProviderNetwork condition error and marks the network as 'not ready' if conflicts are found. Also, implements periodic checks to detect conflicts with other Provider Networks.
- Configuration Option: Adds a new configuration flag
--enable-check-vlan-conflict
to enable or disable the VLAN conflict check feature. - Node Labeling: The daemon now patches nodes with labels indicating the tunnel VLAN ID, which the controller uses to check for conflicts.
Changelog
Click here to see the changelog
- dist/images/install.sh
- Adds
--enable-check-vlan-conflict=true
to kube-ovn-controller's arguments. - Sets a default value for IFACE to
bond0.123
.
- Adds
- pkg/apis/kubeovn/v1/vlan.go
- Adds a
Conflict
field to theVlanStatus
struct to indicate if the VLAN has conflicts.
- Adds a
- pkg/controller/config.go
- Adds a
EnableCheckVlanConflict
field to theConfiguration
struct. - Adds a command-line flag
--enable-check-vlan-conflict
to control whether to enable VLAN conflict checking.
- Adds a
- pkg/controller/subnet.go
- Checks for VLAN conflicts before formatting a subnet if
EnableCheckVlanConflict
is true. Returns an error if the VLAN is in conflict.
- Checks for VLAN conflicts before formatting a subnet if
- pkg/controller/vlan.go
- Imports
fmt
,strconv
, andgithub.com/scylladb/go-set/strset
. - In
handleAddVlan
, checks for VLAN conflicts with node tunnel VLANs and other VLANs. Updates the VLAN status toConflict
if a conflict is found.
- Imports
- pkg/daemon/config.go
- Adds
netlink
import. - Adds
IfaceVlanID
andEnableCheckVlanConflict
fields to theConfiguration
struct. - Adds a command-line flag
--enable-check-vlan-conflict
to control whether to enable VLAN conflict checking. - Caches the tunnel NIC VLAN ID during initialization if
EnableCheckVlanConflict
is enabled. - Adds a
getVLAN
function to retrieve the VLAN ID of a given interface.
- Adds
- pkg/daemon/controller.go
- In
initProviderNetwork
, checks if the VLAN ID is already used by the tunnel interface on the node. Records a ProviderNetwork error if a conflict is found. - In
Run
, patches the node with tunnel VLAN ID labels and starts a periodic check for VLAN conflicts. - Adds
loopCheckVlanConflict
to periodically check for VLAN conflicts between tunnel VLANs and OVS VLANs, and between OVS VLANs and OS VLANs. Records ProviderNetwork errors if conflicts are found.
- In
- pkg/daemon/ovs_linux.go
- Imports
slices
andgithub.com/scylladb/go-set/strset
. - Adds
loopCheckVlanConflict
to check for vlan conflicts. - Adds
patchNodeTunnelVlanLabel
to patch the node with tunnel vlan labels.
- Imports
- pkg/util/const.go
- Adds
TunnelVlanIDLabel
andTunnelUseVlanLabel
constants for node labels.
- Adds
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 VLAN's tale, a tangled web,
Of IDs clashing, causing ebb.
To check and guard, with vigilant eye,
Conflicts resolved, beneath the sky.
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
This pull request introduces a VLAN conflict check feature to prevent the creation of conflicting VLANs in the cluster. The feature is implemented in both the kube-ovn-controller and kube-ovn-cni components. Overall, the code is well-structured and addresses the intended functionality. However, there are some areas where improvements can be made to enhance maintainability, efficiency, and clarity.
Summary of Findings
- VLAN Conflict Check Logic: The VLAN conflict check logic is implemented in both the controller and daemon, leading to potential redundancy and inconsistency. Consolidating this logic into a shared library or webhook would improve maintainability and ensure consistent behavior across components.
- Error Handling in Conflict Detection: The error handling in the VLAN conflict detection loops could be improved. Currently, errors are logged but the loop continues, potentially masking other conflicts. Consider returning immediately upon encountering an error to prevent further processing and ensure that all errors are surfaced.
- Logging Consistency: The logging messages use inconsistent formatting and verbosity levels. Standardizing the logging format and using consistent verbosity levels would improve readability and debuggability.
Merge Readiness
The pull request introduces a valuable feature for preventing VLAN conflicts. However, the identified issues regarding redundant logic, error handling, and logging consistency should be addressed before merging. Addressing these concerns will improve the overall quality and maintainability of the code. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging.
Signed-off-by: zbb88888 <[email protected]>
Signed-off-by: zbb88888 <[email protected]>
Pull Request Test Coverage Report for Build 14372473322Warning: 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]>
Signed-off-by: zbb88888 <[email protected]>
Signed-off-by: zbb88888 <[email protected]>
Signed-off-by: zbb88888 <[email protected]>
Signed-off-by: zbb88888 <[email protected]>
Pull Request
What type of this PR
Examples of user facing changes:
Which issue(s) this PR fixes
Fixes #(issue-number)