-
Notifications
You must be signed in to change notification settings - Fork 483
fix(slr): address family and familypolicy isn't correct #5349
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.
Summary of Changes
Hello @SkalaNetworks, 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 fixes a bug in the SwitchLBRule controller where the generated Kubernetes Service was not correctly configured with the appropriate IP families and family policy based on the specified VIP. This could lead to the Service being created with the wrong address family in dual-stack clusters, preventing endpoints from being generated. The changes introduce logic to dynamically determine the correct IP families and policy by inspecting the VIP string and apply these settings to the Service, ensuring compatibility with the provided VIP addresses.
Highlights
- Bug Fix: SwitchLBRule IP Families: I've addressed a bug where the
ipFamilies
andipFamilyPolicy
for the Service created by a SwitchLBRule were not being correctly determined based on the VIP, potentially causing issues in dual-stack environments depending on the ServiceCIDR order. - Dynamic IP Family Detection: Introduced a new helper function
getIPFamilies
that inspects the provided VIP string (which can contain comma-separated IPs) to determine if it includes IPv4, IPv6, or both, and sets the appropriateIPFamilies
slice andIPFamilyPolicy
(SingleStack
orPreferDualStack
). - Service Update Logic: Modified the
generateHeadlessService
function to call the newgetIPFamilies
helper and apply the determined families and policy to the Service spec, both when creating a new Service and updating an existing one. - IP Protocol Helper: Added a utility function
GetIPAddressProtocol
inpkg/util/address_family.go
to reliably determine if a given IP string is IPv4 or IPv6 using the standardnet
package. - Unit Tests: Added unit tests for the new
getIPFamilies
function to cover single-stack (IPv4, IPv6) and dual-stack (IPv6 then IPv4, IPv4 then IPv6) scenarios.
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.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configureGemini 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 fixes an issue where the IP family and family policy for SwitchLBRule services were not being set accurately. The core change involves a new utility function getIPFamilies
to determine the appropriate settings based on the VIP's IP addresses, and applying these to the generated Kubernetes Service. A critical issue was identified in the new helper function util.GetIPAddressProtocol
which could lead to a panic with invalid IP inputs, and a fix is suggested. Additionally, enhancing the test coverage for getIPFamilies
with edge cases for VIP strings would improve robustness. A minor typo in a test error message was also noted.
b87486f
to
3d85d69
Compare
3d85d69
to
719340e
Compare
d1e72da
to
aed212a
Compare
Signed-off-by: SkalaNetworks <[email protected]>
aed212a
to
b3a2cb1
Compare
Signed-off-by: SkalaNetworks <[email protected]>
Pull Request Test Coverage Report for Build 15605457341Warning: 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 |
Pull Request
What type of this PR
Bug fix on the SwitchLBRules.
The ipFamilies and ipFamilyPolicy aren't honored for the VIP. Because the clusterIP isn't set, K8S determines the family using its defaults.
So if the cluster was installed with a ServiceCIDR that contains the IPv4 range first and the IPv6 second, the family will be set to IPv4 by default. This works in nearly every case.
But if the ServiceCIDR contains the IPv6 range first and the IPv4 range second, the Service is created with ipFamily IPv6, eventhough the VIP might be an IPv4. This breaks the SLR and no endpoint is generated for the service.
The VIP might contain IPv4/IPv6 or a mix of the two. Depending on the content of the VIP, we detect if the Service should be created with ipFamilies IPv4, IPv6 or both. We also compute the ipFamilyPolicy to SingleStack or Dual depending on the number of ipFamilies.