Skip to content

Commit

Permalink
Add namespace to informer
Browse files Browse the repository at this point in the history
  • Loading branch information
triarius committed Apr 29, 2023
1 parent c27a72a commit 03e89d4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func Run(
})
limiter := scheduler.NewLimiter(logger.Named("limiter"), sched, cfg.MaxInFlight)

informerFactory, err := scheduler.NewInformerFactory(k8sClient, cfg.Tags)
informerFactory, err := scheduler.NewInformerFactory(k8sClient, cfg.Namespace, cfg.Tags)
if err != nil {
logger.Fatal("failed to create informer", zap.Error(err))
}
Expand Down
2 changes: 2 additions & 0 deletions internal/controller/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func New(logger *zap.Logger, client kubernetes.Interface, cfg Config) *worker {
// returns an informer factory configured to watch resources (pods, jobs) created by the scheduler
func NewInformerFactory(
k8s kubernetes.Interface,
namespace string,
tags []string,
) (informers.SharedInformerFactory, error) {
hasTag, err := labels.NewRequirement(config.TagLabel, selection.In, config.TagsToLabels(tags))
Expand All @@ -61,6 +62,7 @@ func NewInformerFactory(
factory := informers.NewSharedInformerFactoryWithOptions(
k8s,
0,
informers.WithNamespace(namespace),
informers.WithTweakListOptions(func(opt *metav1.ListOptions) {
opt.LabelSelector = labels.NewSelector().Add(*hasTag, *hasUUID).String()
}),
Expand Down

0 comments on commit 03e89d4

Please sign in to comment.