Skip to content

Commit 68b3f1e

Browse files
authored
Merge pull request #3783 from serathius/watchlist-namepace
Allow increating informer on all namespaces
2 parents 1ece6ff + 45b7f63 commit 68b3f1e

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

util-images/watch-list/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
PROJECT ?= k8s-staging-perf-tests
22
IMG = gcr.io/$(PROJECT)/watch-list
3-
TAG = v0.0.2
3+
TAG = v0.0.3
44

55
all: push
66

util-images/watch-list/main.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func main() {
8282
ctxInformer, cancelInformers := context.WithCancel(ctx)
8383
defer cancelInformers()
8484

85-
klog.Infof("Starting %d informers for gvr = %v, targetNamespace = %s", informerCount, targetGVR, targetNamespace)
85+
klog.Infof("Starting %d informers for gvr = %v, targetNamespace = %q", informerCount, targetGVR, targetNamespace)
8686
informersSynced, err := startInformersForResource(ctxInformer, client, targetGVR, informerCount, targetNamespace)
8787
if err != nil {
8888
return false, err
@@ -105,7 +105,7 @@ func registerFlags() {
105105
klog.InitFlags(flag.CommandLine)
106106

107107
flag.StringVar(&kubeconfig, "kubeconfig", "", "path to kubeconfig.")
108-
flag.StringVar(&targetNamespace, "namespace", "huge-secrets-1", "namespace that hosts the target resource. If empty a default (huge-secrets-1) value will be used.")
108+
flag.StringVar(&targetNamespace, "namespace", "", "namespace to run informers for. If empty will open on all namespaces.")
109109
flag.IntVar(&informerCount, "count", 4, "the number of informers per targetNamespace to run. If empty a default (4) value will be used.")
110110
flag.DurationVar(&testTimeout, "timeout", time.Minute, "timeout duration for the test")
111111
flag.BoolVar(&enableWatchListAlphaFeature, "enableWatchListFeature", false, "whether to set KUBE_FEATURE_WatchListClient env var")
@@ -118,10 +118,14 @@ func startInformersForResource(ctx context.Context, client kubernetes.Interface,
118118
factories := make([]informers.SharedInformerFactory, 0, count)
119119

120120
for i := 0; i < count; i++ {
121+
opts := []informers.SharedInformerOption{}
122+
if namespace != "" {
123+
opts = append(opts, informers.WithNamespace(namespace))
124+
}
121125
factory := informers.NewSharedInformerFactoryWithOptions(
122126
client,
123127
0,
124-
informers.WithNamespace(namespace),
128+
opts...,
125129
)
126130
inf, err := factory.ForResource(gvr)
127131
if err != nil {

0 commit comments

Comments
 (0)