Skip to content

Commit

Permalink
fix pg controller create redundancy podGroup when schedulerName isn't…
Browse files Browse the repository at this point in the history
… matched

Signed-off-by: liuyuanchun <[email protected]>
  • Loading branch information
liuyuanchun11 committed Aug 13, 2024
1 parent fadc9c8 commit 9a57bd6
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions pkg/controllers/podgroup/pg_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ package podgroup

import (
"slices"


appsv1 "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/util/wait"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/client-go/informers"
Expand Down Expand Up @@ -108,9 +109,23 @@ func (pg *pgcontroller) Initialize(opt *framework.ControllerOption) error {
if utilfeature.DefaultFeatureGate.Enabled(features.WorkLoadSupport) {
pg.rsInformer = pg.informerFactory.Apps().V1().ReplicaSets()
pg.rsSynced = pg.rsInformer.Informer().HasSynced
pg.rsInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
AddFunc: pg.addReplicaSet,
UpdateFunc: pg.updateReplicaSet,
pg.rsInformer.Informer().AddEventHandler(cache.FilteringResourceEventHandler{
FilterFunc: func(obj interface{}) bool {
switch v := obj.(type) {
case *appsv1.ReplicaSet:
if slices.Contains(pg.schedulerNames, v.Spec.Template.Spec.SchedulerName) {
return true
}

return false
default:
return false
}
},
Handler: cache.ResourceEventHandlerFuncs{
AddFunc: pg.addReplicaSet,
UpdateFunc: pg.updateReplicaSet,
},
})
}
return nil
Expand Down

0 comments on commit 9a57bd6

Please sign in to comment.