-
Notifications
You must be signed in to change notification settings - Fork 434
[Misc] enhance headless service sync with update logic #1311
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 @omerap12, 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 stormservice
controller's ability to manage headless services by extending its synchronization logic. It now not only creates new headless services when needed but also correctly updates existing ones to ensure their properties align with the desired state. This improvement is thoroughly validated by new unit tests covering both creation and update scenarios.
Highlights
- Headless Service Sync Enhancement: The
syncHeadlessService
function in thestormservice
controller has been updated to correctly handle updates of existing headless services, ensuring theirType
,Selector
, andClusterIP
properties are synchronized. Previously, this function only handled the creation of new services. - Unit Test Coverage: Comprehensive unit tests have been added for the
syncHeadlessService
function, covering both the creation of new headless services and the updating of existing ones, significantly improving test coverage and reliability for this critical synchronization logic.
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 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 or fill out our survey 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 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 enhances the headless service synchronization logic to handle updates, which is a great improvement. My review focuses on a critical error handling bug in the new logic and suggests an optimization to avoid unnecessary API calls. I've also pointed out a minor issue in the new test code. Overall, the changes are in the right direction.
3053363
to
dfb5fbf
Compare
} | ||
return err // Return other errors immediately | ||
} |
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.
Can we use something like this? (This code seems more concise)
if !isServiceEqual(headlessService, expectedService) {
headlessService.Spec = expectedService.Spec
if err := r.Client.Update(ctx, headlessService); err != nil {
return fmt.Errorf("failed to update headless service: %w", err)
}
r.EventRecorder.Eventf(service, corev1.EventTypeNormal, "Updated", "Headless Service updated")
}
func isServiceEqual(a, b *corev1.Service) bool {
return a.Spec.Type == b.Spec.Type &&
apiequality.Semantic.DeepEqual(a.Spec.Selector, b.Spec.Selector) &&
a.Spec.ClusterIP == b.Spec.ClusterIP
}
Also, I'm not sure why we need a sync update. The headless service seems to be injected internally at the beginning and will not involve modifications? Right? 🤔
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.
I'm not sure if this is needed either, but it's part of the reconciliation loop, so it seems okay to have it. Still, I'm not completely sure.
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 headless service seems to be injected internally at the beginning and will not involve modifications? Right?
Yes. I think the projection is helpful just in case user modified the service themselves. no harm to add it with enough coverage
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.
I think what @googs1025 suggest is clean and concise. We can adopt the way to compare the resources.
@omerap12 could you help resolve the lint issue and rebase the main branch?
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.
Yeah sure. thanks folks
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.
sgtm
/cc @googs1025 I will leave review work to you. let me whether the change looks good to you. |
dfb5fbf
to
a7c1a9b
Compare
a7c1a9b
to
920412f
Compare
LGTM. |
Signed-off-by: Omer Aplatony <omerap12@gmail.com>
920412f
to
5c32b1c
Compare
…1311) Signed-off-by: Omer Aplatony <omerap12@gmail.com>
Pull Request Description
While adding tests to
pkg/controller/stormservice/sync_test.go
I noticed that currently the headless service sync logic only handles creation of new services without properly updating existing ones. This PR enhances the sync logic to handle both creation and updates, ensuring service properties (Type, Selector, ClusterIP) stay properly synchronized. Added comprehensive unit tests to verify both scenarios.Related Issues
Resolves: NONE
Important: Before submitting, please complete the description above and review the checklist below.
Contribution Guidelines (Expand for Details)
We appreciate your contribution to aibrix! To ensure a smooth review process and maintain high code quality, please adhere to the following guidelines:
Pull Request Title Format
Your PR title should start with one of these prefixes to indicate the nature of the change:
[Bug]
: Corrections to existing functionality[CI]
: Changes to build process or CI pipeline[Docs]
: Updates or additions to documentation[API]
: Modifications to aibrix's API or interface[CLI]
: Changes or additions to the Command Line Interface[Misc]
: For changes not covered above (use sparingly)Note: For changes spanning multiple categories, use multiple prefixes in order of importance.
Submission Checklist
By submitting this PR, you confirm that you've read these guidelines and your changes align with the project's contribution standards.