Skip to content

Conversation

omerap12
Copy link
Contributor

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

  • PR title includes appropriate prefix(es)
  • [ x Changes are clearly explained in the PR description
  • New and existing tests pass successfully
  • Code adheres to project style and best practices
  • Documentation updated to reflect changes (if applicable)
  • Thorough testing completed, no regressions introduced

By submitting this PR, you confirm that you've read these guidelines and your changes align with the project's contribution standards.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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 the stormservice controller has been updated to correctly handle updates of existing headless services, ensuring their Type, Selector, and ClusterIP 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

  1. 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.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a 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.

@omerap12 omerap12 force-pushed the fix-headless-service-sync branch 2 times, most recently from 3053363 to dfb5fbf Compare July 22, 2025 17:47
}
return err // Return other errors immediately
}
Copy link
Collaborator

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? 🤔

Copy link
Contributor Author

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.

Copy link
Collaborator

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

Copy link
Collaborator

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sure. thanks folks

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sgtm

@Jeffwan
Copy link
Collaborator

Jeffwan commented Jul 23, 2025

/cc @googs1025 I will leave review work to you. let me whether the change looks good to you.

@omerap12 omerap12 force-pushed the fix-headless-service-sync branch from dfb5fbf to a7c1a9b Compare July 23, 2025 17:25
@Jeffwan Jeffwan force-pushed the fix-headless-service-sync branch from a7c1a9b to 920412f Compare July 23, 2025 17:47
@googs1025
Copy link
Collaborator

LGTM.

Signed-off-by: Omer Aplatony <omerap12@gmail.com>
@Jeffwan Jeffwan force-pushed the fix-headless-service-sync branch from 920412f to 5c32b1c Compare July 24, 2025 04:49
@Jeffwan Jeffwan merged commit 50b7368 into vllm-project:main Jul 24, 2025
14 checks passed
ae86zhizhi pushed a commit to ae86zhizhi/aibrix that referenced this pull request Jul 30, 2025
…1311)

Signed-off-by: Omer Aplatony <omerap12@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants