Skip to content

Commit

Permalink
Merge pull request #3675 from liuyuanchun11/fixPgRelease1.9
Browse files Browse the repository at this point in the history
[cherry-pick for release-1.9]fix pg controller create redundancy podGroup when schedulerName isn't matched
  • Loading branch information
volcano-sh-bot authored Aug 18, 2024
2 parents 1a696ee + 95184cc commit 682c39a
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions pkg/controllers/podgroup/pg_controller_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package podgroup
import (
"context"
"encoding/json"
"slices"
"strings"

appsv1 "k8s.io/api/apps/v1"
Expand Down Expand Up @@ -87,15 +88,19 @@ func (pg *pgcontroller) addReplicaSet(obj interface{}) {
podList, err := pg.kubeClient.CoreV1().Pods(rs.Namespace).List(context.TODO(),
metav1.ListOptions{LabelSelector: metav1.FormatLabelSelector(&selector)})
if err != nil {
klog.Errorf("Failed to list pods for ReplicaSet <%s/%s>: %v", rs.Namespace, rs.Name, err)
klog.Errorf("Failed to list pods for ReplicaSet %s: %v", klog.KObj(rs), err)
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))
if !slices.Contains(pg.schedulerNames, pod.Spec.SchedulerName) {
klog.V(4).Infof("Pod %s field SchedulerName is not matched", klog.KObj(&pod))
return
}
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)
}
}
}
Expand Down

0 comments on commit 682c39a

Please sign in to comment.