Skip to content
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

fix pg controller create redundancy podGroup when schedulerName isn't matched #3672

Merged
merged 1 commit into from
Aug 15, 2024

Conversation

liuyuanchun11
Copy link
Contributor

@liuyuanchun11 liuyuanchun11 commented Aug 13, 2024

fix issue #3671

Check whether the value of pod.spec.schedulerName is matched before creating a podGroup.

@volcano-sh-bot volcano-sh-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 13, 2024
@volcano-sh-bot volcano-sh-bot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 13, 2024
Copy link
Member

@hwdef hwdef 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 Aug 13, 2024
@@ -93,6 +94,10 @@ func (pg *pgcontroller) addReplicaSet(obj interface{}) {
if podList != nil && len(podList.Items) > 0 {
pod := podList.Items[0]
klog.V(4).Infof("Try to create podgroup for pod %s/%s", pod.Namespace, pod.Name)
if !slices.Contains(pg.schedulerNames, pod.Spec.SchedulerName) {
klog.V(4).Infof("pod %s/%s field SchedulerName is not matched", pod.Namespace, pod.Name)
Copy link
Member

Choose a reason for hiding this comment

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

Please change pod to upper case.

Copy link
Member

Choose a reason for hiding this comment

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

And we can use klog.Kobj to print pod.namespace and pos.name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@volcano-sh-bot volcano-sh-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed lgtm Indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Aug 14, 2024
return
}
if podList != nil && len(podList.Items) > 0 {
pod := podList.Items[0]
klog.V(4).Infof("Try to create podgroup for pod %s/%s", pod.Namespace, pod.Name)
klog.V(4).Infof("Try to create podgroup for pod %s", klog.KObj(&pod))
Copy link
Member

Choose a reason for hiding this comment

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

klog.KObj(pod)) is ok: )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The value must be a pointer. pod:= podList.Items[0], pod is not a pointer.

Copy link
Member

Choose a reason for hiding this comment

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

OK.

err := pg.createNormalPodPGIfNotExist(&pod)
if err != nil {
klog.Errorf("Failed to create PodGroup for pod <%s/%s>: %v", pod.Namespace, pod.Name, err)
klog.Errorf("Failed to create PodGroup for pod %s: %v", klog.KObj(&pod), err)
Copy link
Member

Choose a reason for hiding this comment

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

same above.

@Monokaix
Copy link
Member

/approve

@volcano-sh-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Monokaix

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

The pull request process is described here

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 Aug 15, 2024
@lowang-bh
Copy link
Member

/lgtm

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/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants