Skip to content

Conversation

@volcano-sh-bot
Copy link
Contributor

This is an automated cherry-pick of #4792

NONE

Replicasets have created a podgroup that wasn't used by the pods
when the "scheduling.k8s.io/group-name" annotation was on the pods.

Signed-off-by: Hajnal Máté <hajnalmt@gmail.com>
Minor error logging enhancements in the podGroup test cases
additionally adding two test cases that will cover these problems
when the annotation is present but the podgroup is created.

Signed-off-by: Hajnal Máté <hajnalmt@gmail.com>
@gemini-code-assist
Copy link

Summary of Changes

Hello @volcano-sh-bot, 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 addresses a potential issue where the PodGroup controller might redundantly create new PodGroups for pods that are already correctly annotated with an existing PodGroup. It introduces a safeguard to prevent this behavior, ensuring that pods with the KubeGroupNameAnnotationKey are not re-processed for new PodGroup creation. The changes also include improved error reporting in tests and a minor refactoring for Go idiomatic style.

Highlights

  • Prevent Duplicate PodGroup Creation: Introduced a check in the addReplicaSet handler to prevent the creation of new PodGroups for pods that are already associated with an existing PodGroup via the KubeGroupNameAnnotationKey annotation.
  • Improved Error Logging: Enhanced error messages in Test_createOrUpdateNormalPodPG to include the specific object (StatefulSet or PodGroup) that caused the error, aiding in debugging.
  • New Test Cases for Annotation Handling: Added TestNoPodGroupCreatedForWhenKubeGroupNameAnnotationExists to validate that the controller correctly avoids creating new PodGroups for ReplicaSet and StatefulSet pods that already possess the KubeGroupNameAnnotationKey.
  • Go Idiomatic Loop Refactoring: Refactored a for loop in pg_controller.go from for i := 0; i < int(pg.workers); i++ to for range int(pg.workers) for better Go idiomacy when the loop index is not explicitly used.
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 by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

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 pull request 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. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

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.

@volcano-sh-bot volcano-sh-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 17, 2025
Copy link

@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 cherry-picks a fix for handling KubeGroupNameAnnotation for ReplicaSets. The change prevents the creation of a new PodGroup if a pod managed by a ReplicaSet already belongs to one. This is the correct behavior and aligns it with how StatefulSets are handled. The other changes, such as using a for range loop and improving test error logging, are also good improvements. The new test case for the fix is comprehensive. I've left one comment regarding code duplication in the new test, which could be addressed to improve maintainability.

Comment on lines +1338 to +1344
pgList, err := c.vcClient.SchedulingV1beta1().PodGroups(namespace).List(context.TODO(), metav1.ListOptions{})
assert.NoError(t, err)
names := make([]string, 0, len(pgList.Items))
for _, pg := range pgList.Items {
names = append(names, pg.Name)
}
assert.Equal(t, 1, len(pgList.Items), "Expected 1 PodGroup, found %d: %v", len(pgList.Items), names)

Choose a reason for hiding this comment

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

medium

This block of code for asserting the PodGroup count is duplicated in the StatefulSet test case below (lines 1409-1415). To improve maintainability and reduce duplication, consider extracting this logic into a helper function. This function could take the testing object t, the controller, namespace, and expected count as arguments, and provide a detailed failure message if the assertion fails.

Copy link
Contributor

Choose a reason for hiding this comment

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

Not needed.

Copy link
Contributor

@hajnalmt hajnalmt left a comment

Choose a reason for hiding this comment

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

/lgtm

@volcano-sh-bot volcano-sh-bot added the lgtm Indicates that a PR is ready to be merged. label Dec 17, 2025
@hajnalmt
Copy link
Contributor

/retest

Copy link
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

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

/lgtm

@volcano-sh-bot
Copy link
Contributor Author

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hajnalmt, hzxuzhonghu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@volcano-sh-bot volcano-sh-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 18, 2025
@volcano-sh-bot volcano-sh-bot merged commit 1368d23 into volcano-sh:release-1.13 Dec 18, 2025
16 of 25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants